I have a server-side app that auths using the Client Credential Flow i.e:
$session = new SpotifyWebAPI\Session($this->clientId_,$this->clientSecret_);
$session->requestCredentialsToken();
$this->accessToken_ = $session->getAccessToken();
I then attempt to read a normal user playlist for example:
$uri='spotify:playlist:0inHe5mbRJoHBtPl8dWMYg';
$playlist = $this->spotify_->api()->getPlaylistTracks($uri, ['market' => 'GB','offset' => $offset, 'limit' => $limit]);
print_r($playlist);
die();
I get the expected results i.e. the tracks in the users playlist that I see in the Spotify app.
If I try to do the same with a playlist a smart playlist owned by Spotify for instance "Daily Mix"
$uri='spotify:playlist:37i9dQZF1E395IXQUXa6QW';
$playlist = $this->spotify_->api()->getPlaylistTracks($uri, ['market' => 'GB','offset' => $offset, 'limit' => $limit]);
print_r($playlist);
die();
Again it works as fine and as expected.
If I then try a Playlist owned by Spotify in this case "Lovely Little Playlist"
https://open.spotify.com/playlist/37i9dQZF1DWXRqgorJj26U?si=a4d80532c53844f8
$uri='spotify:playlist:37i9dQZF1DXbZndSu0dHeI';
$playlist = $this->spotify_->api()->getPlaylistTracks($uri, ['market' => 'GB','offset' => $offset, 'limit' => $limit]);
print_r($playlist);
die();
I get a slightly different tracks being returned than I see in the Spotify app. There is a lot of commonality but there are also differences (though interestingly all tracks are the correct style of music.)
If I try this in the Spotify sandpit console (using the OAuth token generated by the console.)
https://developer.spotify.com/console/get-playlist-tracks/?playlist_id=37i9dQZF1DXbZndSu0dHeI&market=&fields=&limit=&offset=&additional_types=
I get the tracks I see in the Spotify app
And if I copy the curl command generated by the sandpit console and run it on my server:
curl -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DXbZndSu0dHeI/tracks?market=GB" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BQDdrL4L74e_GtbbhDRU0xAYOSV2AMHvntrwacbLdpfBIL9FbMRMJjaoRfSfEdI8kxPqLCtn7AZkHk_HtGjFAC0jOxIgQWlRe-TjNnEoSyinCPa05PaBNUnkXnaCsP7dCOgVQa72aeGw"
It also gives the tracks I see in the Spotify app.
However if I trace down into the Request.php get the Auth token generated by the Client Credentials flow and put into the above curl request i.e.
curl -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DXbZndSu0dHeI/tracks?market=GB" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BQDwQ8vqob0tLLH2hNbpMru7wqxYXZ_3dbolc0gHBnobpUCPBHSDzaJRWPIXZkuZmOj0WjpeBXssPnB0Ne8"
I get a slightly different set of tracks returned. Again commonality but differences.
NB. Market is set to "GB" in both cases and I have checked is_playable is true or 1 in for all tracks
So my questions would be :
-
Is there something else I should be specifying to get the same tracks for both spoti-web-api-php vs sandpit console?
-
Do you think this is to do with the different auth flows or is that a red herring?
3; Do you think this is because "Lovely Little Playlist" is an actually a smart playlist, the tracks being generated dynamically and thus not tightly defined - essentially the behaviour I'm seeing is to be expected.
And finally, If this the right place to ask the question or should I post it on the Spotify dev forums instead.
Many thanks for any insight you can give.
question