Extract token from response url - Spotify API

前端 未结 1 1366
生来不讨喜
生来不讨喜 2021-01-21 23:33

I\'m using this code to get a token from Spotify\'s Web API:



        
相关标签:
1条回答
  • 2021-01-22 00:02

    You need to decode the JSON:

    $response = json_decode($response, true);
    

    Then you'll have an array with the values.

    $token = $response['access_token'];
    

    Also, you're missing a necessary option to obtain the response in this way:

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    

    If not defined, you will get a boolean value instead of the response.

    0 讨论(0)
提交回复
热议问题