There are lots of operations involving user's playlists that can be performed. Remember to request the correct scopes beforehand.
Note: This method is only available to extended quota apps.
$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;
$playlistImage = $api->getPlaylistImage('PLAYLIST_ID');
$playlistItems = $api->getPlaylistItems('PLAYLIST_ID');
foreach ($playlistItems->items as $item) {
$item = $item->item;
echo '<a href="' . $item->external_urls->spotify . '">' . $item->name . '</a> <br>';
}
$api->createPlaylist('USER_ID', [
'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->addPlaylistItems('PLAYLIST_ID', [
'TRACK_URI',
'EPISODE_URI'
]);
$items = [
['uri' => 'TRACK_URI'],
['uri' => 'EPISODE_URI'],
];
$api->deletePlaylistItems('PLAYLIST_ID', $tracks, 'SNAPSHOT_ID');
$items = [
'TRACK_URI',
'EPISODE_URI'
];
$options = [
'insert_before' => 10,
];
$api->updatePlaylistItems('PLAYLIST_ID', $items, $options, 'SNAPSHOT_ID');
Please see the method reference for more available options for each method.
How can I help you explore Laravel packages today?