[GH-ISSUE #105] Scope Processing Issue: Private Playlists #61

Closed
opened 2026-02-27 19:25:51 +03:00 by kerem · 8 comments
Owner

Originally created by @Jack-Anstey on GitHub (Nov 9, 2017).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/105

I am not sure if this is due to my programming of if there is actually a problem with the API itself. My purpose is getting every playlist that a user possesses, including private ones. I am then getting all of the tracks within those playlists. Scope is declared in authorize.php, which points to callback.

$options = [
    	'scope' => [
        	'playlist-read-private',
        	'playlist-read-collaborative'
    	],
    	//this makes it so that the user has to relog every single time
    	'show_dialog' => 'false',
	];

Is the scope. The error occurs in the main processes script. The output is: Not found.
Something went really wrong getting your playlist tracks, come back later
, then it continues with the rests of the tracks inside a playlist as normal. Here is the code where the playlist processing occurs:

$index = 0;
for($row = 0; $row < count($playlistIds); $row++)
{
     try
     {
          $playlistTracks = $api->getUserPlaylistTracks($userId, $playlistIds[$row]);
     }
     catch(Exception $e)
     {
          echo $e->getMessage() . "<br>";
          if ($e->getCode() == 429) 
          {
                // 429 is Too Many Requests
               echo "Rate Limited :/<br>";
               $retryAfter = $lastResponse['headers']['Retry-After']; 
                // Number of seconds to wait before sending another request
                echo " retry after " . $retryAfter . " seconds";
         }
         else
         {
                echo "Something went really wrong getting your playlist tracks, come back later<br>";
	 }
     }

     foreach ($playlistTracks->items as $track) 
     {
	    $allTracks[$index][0] = $track->track->name;
            $allTracks[$index][1] = $track->track->id;
	    $allTracks[$index][1] . "<br>";
	    $index++;
     }
}

I have isolated it to the scope as it only occurs when you add 'playlist-read-private' and at no other time. For more context, the user that I am looking at (me) possesses no private playlists but I don't see any reason this code should not work, leading me to believe that this is an API issue. Please correct me if I am wrong!

Thanks!

Originally created by @Jack-Anstey on GitHub (Nov 9, 2017). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/105 I am not sure if this is due to my programming of if there is actually a problem with the API itself. My purpose is getting every playlist that a user possesses, including private ones. I am then getting all of the tracks within those playlists. Scope is declared in authorize.php, which points to callback. ``` $options = [ 'scope' => [ 'playlist-read-private', 'playlist-read-collaborative' ], //this makes it so that the user has to relog every single time 'show_dialog' => 'false', ]; ``` Is the scope. The error occurs in the main processes script. The output is: _Not found. Something went really wrong getting your playlist tracks, come back later_, then it continues with the rests of the tracks inside a playlist as normal. Here is the code where the playlist processing occurs: ``` $index = 0; for($row = 0; $row < count($playlistIds); $row++) { try { $playlistTracks = $api->getUserPlaylistTracks($userId, $playlistIds[$row]); } catch(Exception $e) { echo $e->getMessage() . "<br>"; if ($e->getCode() == 429) { // 429 is Too Many Requests echo "Rate Limited :/<br>"; $retryAfter = $lastResponse['headers']['Retry-After']; // Number of seconds to wait before sending another request echo " retry after " . $retryAfter . " seconds"; } else { echo "Something went really wrong getting your playlist tracks, come back later<br>"; } } foreach ($playlistTracks->items as $track) { $allTracks[$index][0] = $track->track->name; $allTracks[$index][1] = $track->track->id; $allTracks[$index][1] . "<br>"; $index++; } } ``` I have isolated it to the scope as it only occurs when you add 'playlist-read-private' and at no other time. For more context, the user that I am looking at (me) possesses no private playlists but I don't see any reason this code should not work, leading me to believe that this is an API issue. Please correct me if I am wrong! Thanks!
kerem 2026-02-27 19:25:51 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@andersborgabiro commented on GitHub (Nov 9, 2017):

Some ideas, considering it's "Not found":

Have you tried adding playlist-read-public to scope?

Some songs might not be available for your market. You don't set market.
https://developer.spotify.com/web-api/track-relinking-guide/

There might be more than 100 tracks in one of the playlists. It reads out max 100 tracks per request.

For more: https://developer.spotify.com/web-api/get-playlists-tracks/

<!-- gh-comment-id:343071438 --> @andersborgabiro commented on GitHub (Nov 9, 2017): Some ideas, considering it's "Not found": Have you tried adding playlist-read-public to scope? Some songs might not be available for your market. You don't set market. https://developer.spotify.com/web-api/track-relinking-guide/ There might be more than 100 tracks in one of the playlists. It reads out max 100 tracks per request. For more: https://developer.spotify.com/web-api/get-playlists-tracks/
Author
Owner

@Jack-Anstey commented on GitHub (Nov 9, 2017):

@andersborgabiro 'playlist-read-public' is an "illegal scope" so I don't believe that that's my problem. Also why would it return not found for a playlist with more than 100 tracks? Wouldn't it just stop once it reached 100?

<!-- gh-comment-id:343232868 --> @Jack-Anstey commented on GitHub (Nov 9, 2017): @andersborgabiro 'playlist-read-public' is an "illegal scope" so I don't believe that that's my problem. Also why would it return not found for a playlist with more than 100 tracks? Wouldn't it just stop once it reached 100?
Author
Owner

@andersborgabiro commented on GitHub (Nov 9, 2017):

You're right of course. There's only a playlist-modify-public. I only use modify at the moment.

And it would or should stop without complaints.

But you could check out the market setting.

<!-- gh-comment-id:343237071 --> @andersborgabiro commented on GitHub (Nov 9, 2017): You're right of course. There's only a playlist-modify-public. I only use modify at the moment. And it would or should stop without complaints. But you could check out the market setting.
Author
Owner

@jwilsson commented on GitHub (Nov 10, 2017):

Hi!
Thanks for helping out, @andersborgabiro!

@JackaJacka123 How are you populating $playlistIds? From a call to $api->getUserPlaylists()? If you print $playlistIds when you've requested the playlist-read-private scope, do you see anything strange?

<!-- gh-comment-id:343590150 --> @jwilsson commented on GitHub (Nov 10, 2017): Hi! Thanks for helping out, @andersborgabiro! @JackaJacka123 How are you populating `$playlistIds`? From a call to `$api->getUserPlaylists()`? If you print `$playlistIds` when you've requested the `playlist-read-private` scope, do you see anything strange?
Author
Owner

@TIBBEH13 commented on GitHub (Nov 14, 2017):

I ran into the same 'Not found' error today and this solved it for me:

You request the Playlist Tracks over here:
$playlistTracks = $api->getUserPlaylistTracks($userId, $playlistIds[$row]);

Not the part where it says $userId. I was using the user ID from the connected spotify user, but this needs to be the user ID from the owner of the playlist.

This is my code, which is working on my site:

$playlists = $api->getUserPlaylists($USER_ID);

foreach ($playlists->items as $playlist) {
	$PLAYLIST_ID = $playlist->id;
	$PLAYLIST_USER_ID = $playlist->owner->uri;
	$playlistTracks = $api->getUserPlaylistTracks($PLAYLIST_USER_ID, $PLAYLIST_ID );
}
<!-- gh-comment-id:344421883 --> @TIBBEH13 commented on GitHub (Nov 14, 2017): I ran into the same 'Not found' error today and this solved it for me: You request the Playlist Tracks over here: `$playlistTracks = $api->getUserPlaylistTracks($userId, $playlistIds[$row]);` Not the part where it says `$userId`. I was using the user ID from the connected spotify user, but this needs to be the user ID from the owner of the playlist. This is my code, which is working on my site: ``` $playlists = $api->getUserPlaylists($USER_ID); foreach ($playlists->items as $playlist) { $PLAYLIST_ID = $playlist->id; $PLAYLIST_USER_ID = $playlist->owner->uri; $playlistTracks = $api->getUserPlaylistTracks($PLAYLIST_USER_ID, $PLAYLIST_ID ); } ```
Author
Owner

@Jack-Anstey commented on GitHub (Nov 14, 2017):

@TIBBEH13 That is exactly it! I am personally following different playlists which is why it is not working for me! Thank you so much for figuring that out. I'll close this issue.

<!-- gh-comment-id:344437498 --> @Jack-Anstey commented on GitHub (Nov 14, 2017): @TIBBEH13 That is exactly it! I am personally following different playlists which is why it is not working for me! Thank you so much for figuring that out. I'll close this issue.
Author
Owner

@andersborgabiro commented on GitHub (Nov 14, 2017):

Shouldn't it be owner->id ? Maybe works with both.

<!-- gh-comment-id:344437910 --> @andersborgabiro commented on GitHub (Nov 14, 2017): Shouldn't it be owner->id ? Maybe works with both.
Author
Owner

@jwilsson commented on GitHub (Nov 15, 2017):

@JackaJacka123 Glad we got it figured out!

@TIBBEH13 Thanks for stepping in and helping out!

Closing since we solved it.

<!-- gh-comment-id:344487427 --> @jwilsson commented on GitHub (Nov 15, 2017): @JackaJacka123 Glad we got it figured out! @TIBBEH13 Thanks for stepping in and helping out! Closing since we solved it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#61
No description provided.