PHP code example of pouler / spotify-artists-api

1. Go to this page and download the library: Download pouler/spotify-artists-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pouler / spotify-artists-api example snippets


 declare(strict_types=1);

ponent\HttpClient\CurlHttpClient();
$apiClient = new \PouleR\SpotifyArtistsAPI\SpotifyArtistsAPIClient($httpClient);
$artistsApi = new \PouleR\SpotifyArtistsAPI\SpotifyArtistsAPI($apiClient);

$loginClient = new \PouleR\SpotifyLogin\SpotifyLoginClient($httpClient);
$spotifyLogin = new \PouleR\SpotifyLogin\SpotifyLogin($loginClient);

$spotifyLogin->setClientId('clientId');
$spotifyLogin->setDeviceId('deviceId');

// Log in and get the access token
$accessToken = $spotifyLogin->login('[email protected]','password');

// Use this token for the artists API
$artistsApi->setAccessToken($accessToken);
$upcoming = $artistsApi->getUpcomingReleases('artistId');

print_r($upcoming);

$realtime = $artistsApi->getRealTimeStatistics('artistId', 'trackId');

print_r($realtime);