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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views