jwilsson / spotify-web-api-php
A PHP wrapper for Spotify's Web API.
Installs: 948 253
Dependents: 13
Suggesters: 0
Security: 0
Stars: 867
Watchers: 36
Forks: 156
Open Issues: 1
Requires
- php: ^8.1
- ext-curl: *
Requires (Dev)
- php-coveralls/php-coveralls: ^2.5
- php-mock/php-mock-phpunit: ^2.7
- phpunit/phpunit: ^10.2
- squizlabs/php_codesniffer: ^3.0
- dev-main
- 6.1.1
- 6.1.0
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.7.1
- 5.7.0
- 5.6.0
- 5.5.0
- 5.4.0
- 5.3.0
- 5.2.0
- 5.1.0
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.3.0
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.0
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.12.0
- 2.11.1
- 2.11.0
- 2.10.1
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.12.0
- 1.11.1
- 1.11.0
- 1.10.1
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 0.10.0
- 0.9.0
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
This package is auto-updated.
Last update: 2024-11-21 17:31:56 UTC
README
This is a PHP wrapper for Spotify's Web API. It includes the following:
- Helper methods for all API endpoints:
- Information about artists, albums, tracks, podcasts, audiobooks, and users.
- List music featured by Spotify.
- Playlist and user music library management.
- Spotify catalog search.
- User playback control.
- Authorization flow helpers.
- Automatic refreshing of access tokens.
- Automatic retry of rate limited requests.
- PSR-4 autoloading support.
Requirements
- PHP 8.1 or later.
- PHP cURL extension (Usually included with PHP).
Installation
Install it using Composer:
composer require jwilsson/spotify-web-api-php
Usage
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.
Contributing
Contributions are more than welcome! See CONTRIBUTING.md for more info.
License
MIT license. Please see LICENSE.md for more info.