pouler / spotify-charts-api
PHP Wrapper for spotifycharts.com
Installs: 2 526
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- ext-json: *
- symfony/http-client: ^4.3|^4.4|^5.0|^6
- symfony/property-access: ^4.3|^4.4|^5|^6
- symfony/serializer: ^4.3|^4.4|^5|^6
Requires (Dev)
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.0
Suggests
- pouler/spotify-login: To obtain an access token to be used in API calls
README
This is a PHP wrapper for spotifycharts.com
Requirements
- PHP ^7.4|^8.0
Installation
Install it using Composer:
composer require pouler/spotify-charts-api
Spotify login
You can obtain an access token by using the SpotifyLogin class, this dependency can be installed by using:
composer require pouler/spotify-login
For more information about this project see: https://github.com/PouleR/spotify-login
Example usage
<?php declare(strict_types=1); require 'vendor/autoload.php'; $httpClient = new \Symfony\Component\HttpClient\CurlHttpClient(); $apiClient = new \PouleR\SpotifyChartsAPI\SpotifyChartsAPIClient($httpClient); $spotifyApi = new \PouleR\SpotifyChartsAPI\SpotifyChartsAPI($apiClient); $spotifyApi->setAccessToken('access.token'); $charts = $spotifyApi->getRegionalTopSongs('nl', 'weekly'); echo $result->getDisplayChart()->getChartMetadata()->getReadableTitle() . PHP_EOL; foreach ($charts->getEntries() as $entry) { echo $entry->getChartEntryData()->getCurrentRank() . ' --> ' . $entry->getTrackMetadata()->getTrackName() . PHP_EOL; }