There are lots of operations involving user's playlists that can be performed. Remember to request the correct scopes beforehand.
$playlists = $api->getUserPlaylists('USER_ID', [
'limit' => 5
]);
foreach ($playlists->items as $playlist) {
echo '<a href="' . $playlist->external_urls->spotify . '">' . $playlist->name . '</a> <br>';
}$playlist = $api->getPlaylist('PLAYLIST_ID');
echo $playlist->name;$playlistTracks = $api->getPlaylistTracks('PLAYLIST_ID');
foreach ($playlistTracks->items as $track) {
$track = $track->track;
echo '<a href="' . $track->external_urls->spotify . '">' . $track->name . '</a> <br>';
}$api->createPlaylist([
'name' => 'My shiny playlist'
]);$api->updatePlaylist('PLAYLIST_ID', [
'name' => 'New name'
]);$imageData = base64_encode(file_get_contents('image.jpg'));
$api->updatePlaylistImage('PLAYLIST_ID', $imageData);$api->addPlaylistTracks('PLAYLIST_ID', [
'TRACK_ID',
'TRACK_ID'
]);$tracks = [
'tracks' => [
['id' => 'TRACK_ID'],
['id' => 'TRACK_ID'],
],
];
$api->deletePlaylistTracks('PLAYLIST_ID', $tracks, 'SNAPSHOT_ID');$trackOptions = [
'positions' => [
5,
12,
],
];
$api->deletePlaylistTracks('PLAYLIST_ID', $trackOptions, 'SNAPSHOT_ID');$api->replacePlaylistTracks('PLAYLIST_ID', [
'TRACK_ID',
'TRACK_ID'
]);$api->reorderPlaylistTracks('PLAYLIST_ID', [
'range_start' => 1,
'range_length' => 5,
'insert_before' => 10,
'snapshot_id' => 'SNAPSHOT_ID'
]);Please see the method reference for more available options for each method.