Curl GET Request to the spotify Authorization API
There is a package for Spotify web API try using that
composer require jwilsson/spotify-web-api-php
Before using the Spotify Web API, you'll need to create an app at Spotify’s developer site.
Simple example displaying a user's profile:
require 'vendor/autoload.php';$session = new SpotifyWebAPI\Session( 'CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI');$api = new SpotifyWebAPI\SpotifyWebAPI();if (isset($_GET['code'])) { $session->requestAccessToken($_GET['code']); $api->setAccessToken($session->getAccessToken()); print_r($api->me());} else { $options = [ 'scope' => [ 'user-read-email', ], ]; header('Location: ' . $session->getAuthorizeUrl($options)); die();}
For more instructions and examples, check out the documentation.