LUX
LUX

Reputation: 23

Spotify Follow Playlist

I'm embedding Spotify playlists onto a wordpress website. Embedding the playlists is simple; though I'm having trouble creating a "Follow Playlist" button. I've looked through the Spotify API docs here: Spotify API

I requested the authorization, and got the OAuth Token.

Based on what I've read, I'd assume I'd need to create an html link target such as:

https://api.spotify.com/v1/users/wanderlustfest/playlists/5ehqaKNCIjtIuwNOALskcK/followers

(which doesn't work)

or

curl -X PUT "https://api.spotify.com/v1/users/wanderlustfest/playlists/5ehqaKNCIjtIuwNOALskcK/followers" -H "Accept: application/json" -H "Authorization: Bearer BQD2Wg3K3P1Hk3fisKSWWLERtPmqcfQ5-mwvthR61ebB9i2NOIVIi5rXwrsg1fMkFrXMfui_HG2n65cOR3fzAw0b5KWfmofVMSjbT3yiqEsKz8uNQg8grKpwB2jijF6wvv-RapahtgczV25ePR6S3lilnuSjKaIXbKCrQtrmq7ojkda9k1xbGv2O4B1lAoDU527xbnx6IejInIB6crhCSC7Hsq2jJsbzkgNVKu8vShWyxkuHkVtU-y8mgCRdEOVay_k" -H "Content-Type: application/json" --data "{\"public\":true}"

(which I have no idea what to do with)

This is an example playlist that I'm trying to embed: This is the example playlist that I'm trying to get the Follow code for: DJ Taz Rashid

Playlist Author: wanderlustfest

Playlist ID: 5ehqaKNCIjtIuwNOALskcK

If someone could help me figure out how to get this Spotify Follow Playlist feature working, I'd greatly appreciate it!!!

Upvotes: 2

Views: 1555

Answers (1)

José M. Pérez
José M. Pérez

Reputation: 3279

The request to the Web API fails because you are probably making a GET request, not providing an access token, nor a body, which is required by that specific endpoint. That's what the curl command is trying to show.

If you are having difficulties with this I recommend you to use one of the wrappers that will make it easier for you to use the Web API using your preferred programming language.

If you are familiar with Javascript you can see an example of a button to follow a playlist using the Web API in this JSFiddle. The relevant code:

  $.ajax({
      url: 'https://api.spotify.com/v1/users/wanderlustfest/playlists/5ehqaKNCIjtIuwNOALskcK/followers',
      headers: {
         'Authorization': 'Bearer ' + <your_access_token>
      },
      method: 'PUT',
      success: function() {
          // do something
      },
      dataType: 'html',
      error: function(e) {
          console.error(e);
      }
  });

Upvotes: 2

Related Questions