Reply

Add to playlist button?

dbbrante
Casual Listener

Hello,

 

I have the spotify iframe player on my site but would also like to add an "add song to playlist" button on my site. Is there such a button? If yes, how do I implement it?

 

thanks!


D

3 Replies

Dreadlord
Community Legend

Hello @dbbrante,

 

You can use the Spotify Web API:

 

Add Tracks to a Playlist

Description Add Tracks to a Playlist docs                                                                       
Endpoint https://api.spotify.com/v1/users/{user_id}/playlists/{playlist_id}/tracks
HTTP Method POST
OAuth Required
OAuth Scope playlist-modify-public, playlist-modify-private

 

 
 
 
 

dbbrante
Casual Listener
Cool, are there any live examples of such a button outside spotify? Would be interested to see. Also, will I as the site owner know how many times someone added the song to their playlists?

Dreadlord
Community Legend

Hey @dbbrante,

 

I don't know any, but the example in the doc is quite good.

As for the counter, I can offer you generic html/js counter:

 

<html>
<head>
    <title>Space Clicker</title>
</head>

<body>
    <script type="text/javascript">
    var clicks = 0;
    function onClick() {
        clicks += 1;
        document.getElementById("clicks").innerHTML = clicks;
    };
    </script>
    <button type="button" onClick="onClick()">Click me</button>
    <p>Clicks: <a id="clicks">0</a></p>

</body></html>

Source.

SUGGESTED POSTS