Closed upgrader-dev closed 8 months ago
Hey Benjamin!
In addition to setting the limit
you can also set the offset
on subsequent requests to skip the first X number of items.
For example:
$limit = 20;
$offset = 0;
$allPlaylists = [];
$next = '';
do {
$myPlaylists = $api->getMyPlaylists([
'limit' => $limit,
'offset' => $offset,
]);
$allPlaylists[] = $myPlaylists;
$next = $myPlaylists->next;
$offset += $limit;
} while ($next != null);
print_r($allPlaylists);
Cheers, Jonathan
Ok thank you
Hello,
I'm trying to get all the playlists of a user with the method getMyPlaylists() of SpotifyWebAPI class with a limit of 20 for example. My aim is not to load the entire playlist collection to save Spotify server's usage.
So I plan tu use the 'next' property of the response (which is the uri to request to get the next page results).
I'm a beginner here, but as far as I understand, there is no such method to get the next page of playlists, and I can't use the method sendRequest() of SpotifyWebAPI class because it's protected.
If my understanding is correct maybe i could suggest a new method getNextPlaylistsPage($nextUri).
What do you think about that?
Benjamin