'a87fb4dbed30475b8cec38523dff53e2', 'client_secret' => 'd7c89d0753ef4068bba1678c6cf26ed6', 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $url ); curl_setopt($ch, CURLOPT_URL,"https://accounts.spotify.com/api/token"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if(curl_errno($ch)){ echo 'CURL Error: '. curl_error($ch); } curl_close($ch); return $response; } /* * Refresh a token * Creates a request to Spotify, which returns a new access_token, refresh_token and token_expiry object * @var $refresh_token = string */ function refreshToken($refresh_token){ $ch = curl_init(); $post_data = array( 'client_id' => 'a87fb4dbed30475b8cec38523dff53e2', 'client_secret' => 'd7c89d0753ef4068bba1678c6cf26ed6', 'grant_type' => 'refresh_token', 'refresh_token' => $refresh_token ); curl_setopt($ch, CURLOPT_URL,"https://accounts.spotify.com/api/token"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $exec = curl_exec($ch); $info = curl_getinfo($ch); $response = array( 'exec' => $exec, 'response_code' => $info['http_code'] ); curl_close ($ch); return $response; }