php - Spotify request token returns invalid_client -
i hope can me here:
i have application should use spotify api. after request authorization itself, stuck @ requesting token. related code follows:
function post($content, $url,$clientid,$clientsecret) { $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_customrequest, "post"); curl_setopt($ch, curlopt_postfields, $content); curl_setopt($ch, curlopt_httpheader, array( 'content-type: application/x-www-form-urlencoded', 'authorization: basic '.base64_encode($clientid).':'.base64_encode($clientsecret))); return curl_exec($ch); } $clientid="4df42e27a76d41f9961b0952102fexxx"; $clientsecret="3088a8b6132b40dc980540880cf5bxxx"; $content=array( 'grant_type' => 'authorization_code', 'code' => $_get["code"], 'redirect_uri' => 'http%3a%2f%2fhome.xxx.de%2ftoken.php', ); echo post($content,"https://accounts.spotify.com/api/token",$clientid,$clientsecret);
unfortunatly, result {"error":"invalid_client"} , have no idea why...
authorization
required.
base 64 encoded string contains client id , client secret key. field must have format:
authorization: basic <base64 encoded client_id:client_secret>
i read base64_encode($clientid.':'.$clientsecret)
Comments
Post a Comment