Stars: 832
Forks: 176
Pull Requests: 71
Issues: 195
Watchers: 37
Last Updated: 2023-08-01 17:42:29
A PHP wrapper for Spotify's Web API.
License: MIT License
Languages: PHP
This is a PHP wrapper for Spotify's Web API. It includes the following:
Install it using Composer:
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.
Note: Applications created after 2021-05-27 might need to perform some extra steps.
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.
The Spotify Web API Console can also be of great help when trying out the API.
Contributions are more than welcome! See CONTRIBUTING.md for more info.
MIT license. Please see LICENSE.md for more info.