Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Spotify Web Api Php Laravel Package

jwilsson/spotify-web-api-php

View on GitHub
Deep Wiki
Context7

Managing a User's Playlists

There are lots of operations involving user's playlists that can be performed. Remember to request the correct scopes beforehand.

Listing a user's playlists

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>';
}

Getting info about a specific playlist

$playlist = $api->getPlaylist('PLAYLIST_ID');

echo $playlist->name;

Getting the image of a user's playlist

$playlistImage = $api->getPlaylistImage('PLAYLIST_ID');

Getting all items in a playlist

$playlistItems = $api->getPlaylistItems('PLAYLIST_ID');

foreach ($playlistItems->items as $item) {
    $item = $item->item;

    echo '<a href="' . $item->external_urls->spotify . '">' . $item->name . '</a> <br>';
}

Creating a new playlist

$api->createPlaylist('USER_ID', [
    'name' => 'My shiny playlist'
]);

Updating the details of a user's playlist

$api->updatePlaylist('PLAYLIST_ID', [
    'name' => 'New name'
]);

Updating the image of a user's playlist

$imageData = base64_encode(file_get_contents('image.jpg'));

$api->updatePlaylistImage('PLAYLIST_ID', $imageData);

Adding tracks to a user's playlist

$api->addPlaylistItems('PLAYLIST_ID', [
    'TRACK_URI',
    'EPISODE_URI'
]);

Delete items from a user's playlist

$items = [
    ['uri' => 'TRACK_URI'],
    ['uri' => 'EPISODE_URI'],
];

$api->deletePlaylistItems('PLAYLIST_ID', $tracks, 'SNAPSHOT_ID');

Updating the items in a playlist

$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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle