Spotify API没有提供令牌

时间:2017-08-23 08:50:34

标签: php oauth-2.0 spotify guzzle

Spotify API授权如何运作?我已经阅读了Spotify和Guzzle文档,将其中的一个放在一起:

    $client = new GuzzleHttp\Client();
    $res = $client->get('https://api.spotify.com/v1/me', [
        'Authorization' =>  ['Bearer ' . $session_owner->spotify_token],
    ]);

    echo $res->getStatusCode(); // 200
    echo $res->getBody();

但是收到此错误消息:

  

"错误":{       " status":401,       "消息":"没有提供令牌" }

1 个答案:

答案 0 :(得分:2)

    $res = $client->post('https://api.spotify.com/v1/me', [
        'headers' => [
            'Authorization' =>  ['Bearer ' . $session_owner->spotify_token],
        ]
    ]);