Php Spotify请求令牌返回无效的\u客户端

Php Spotify请求令牌返回无效的\u客户端,php,api,http-post,authorization,spotify,Php,Api,Http Post,Authorization,Spotify,我希望有人能在这里帮助我: 我有一个应用程序应该使用SpotifyAPI。但是,在请求授权之后,我就一直在请求令牌。相关代码如下: function post($content, $url,$clientId,$clientSecret) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_set

我希望有人能在这里帮助我:

我有一个应用程序应该使用SpotifyAPI。但是,在请求授权之后,我就一直在请求令牌。相关代码如下:

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);
不幸的是,结果是{“error”:“invalid_client”},我不知道为什么

授权书

必需的

包含客户端ID和客户端密钥的Base 64编码字符串。该字段必须具有以下格式:

授权:基本
我把它理解为
base64\u encode($clientId.:'。$clientSecret)

授权书

必需的

包含客户端ID和客户端密钥的Base 64编码字符串。该字段必须具有以下格式:

授权:基本

我将此理解为
base64\u encode($clientId.:“.$clientSecret)

我真的希望你的秘密与你在这里发布的秘密大不相同(不仅仅是被替换的3 x…,只有约100万种可能需要检查)。您是否也尝试过
base64_encode($clientId.:“.$clientSecret)
?我真的希望您的秘密与您在这里发布的秘密大不相同(不仅仅是更换了3个…,只有约100万个可能需要检查)。您还尝试过
base64\u编码($clientId.:'。$clientSecret)
  Authorization: Basic <base64 encoded client_id:client_secret>