Download the PHP package arunchaitanyajami/spotify-webapi-sdk without Composer
On this page you can find all versions of the php package arunchaitanyajami/spotify-webapi-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arunchaitanyajami/spotify-webapi-sdk
More information about arunchaitanyajami/spotify-webapi-sdk
Files in arunchaitanyajami/spotify-webapi-sdk
Package spotify-webapi-sdk
Short Description Spotify WebApi PHP Library
License MIT
Informations about the package spotify-webapi-sdk
PHP SDK For Spotify Web Api
requires php >= 7.2
- Integrated Pagination
- Automated Token Refresh
- Separate Services Files For All Api References
- Guzzle Requests
Installation
composer require arunchaitanyajami/spotify-webapi-sdk
Doesnt have token?
Option 1 - Get access token with client credentials
Option 2 - Get access token with code authorization (recommended)
Before make requests you must add yours Redirect URIs to https://developer.spotify.com/dashboard
Get redirect url for code:
After signup in spotify you will be redirected back to provided above callback url (http://yoursite.com/callback) with parameter $_GET['code'] with the code that can get token with following command:
And you will receive array with accessToken and refreshToken in the example above $tokens.
Access/Refresh Tokens
Spotify tokens are valid 1 hour. If your token is expired and you make a call, the sdk auto renew access token with provided refresh token in every query (as there is no safe place to automatically save it).
If you set $spotifyWebApi->returnNewTokenIfIsExpired(true); before your request calls, if access token is expired will be returned from the query, object with the new access_token, then you can save it in database and recall request with a fresh Access token. You can also generate access token with refresh token manually with
and save final expire timestamp with time() + $result->expires_in. You can manualy generate new access token every time when saved in your database expired time is end.
Suggestions
It is good practise to add ip of the api that you call in the hosts file in yours server os because Guzzle sometime cannot resolve the dns.
Can increase your execution time of scripts ini_set('max_execution_time', XXX); and set_time_limit(XXX);