I'm trying to allow users to login to my site using their spotify account but receive
{"error":"server_error","error_description":"Unexpected status: 415"}
when receiving the JSON response.
This is the code I'm using:
if (isset($_GET['code']) ) {
echo $_GET['code'];
$scode = $_GET['code'];
$surl2 = "https://accounts.spotify.com/api/token";
$sdata2=array("grant_type"=>"authorization_code","code"=>$scode,"redirect_uri"=>$sredicturl,"client_id"=>$Sclient,"client_secret"=>$Ssecret);
$sch2=curl_init($surl2);
curl_setopt($sch2,CURLOPT_POST,true);
curl_setopt($sch2,CURLOPT_POSTFIELDS,$sdata2);
curl_setopt($sch2,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($sch2,CURLOPT_RETURNTRANSFER,1);
$sjson_response2=curl_exec($sch2);
curl_close($sch2);
echo"<br/>".$sjson_response2;
I'm at number 4 in the spotify documentation... https://developer.spotify.com/web-api/authorization-guide/
Thanks