Add track to playlist using Deezer API and PHP

1.4k Views Asked by At

I have looked through the documentation of the Deezer API and I am unable to fully comprehend how to add a track through their API with PHP, if you can at all. - This is lack of understanding rather than poor documentation.

I am looking for a way to add 100 tracks to a new playlist each week. I have read up on Deez's use of OAuth and the Track API object but I can not for the life me understand how to make the authentication.

In essence, what I am trying to achieve is a web based application where a user can add songs to a playlist. From what I believe, Deezer's OAuth asks a user to allow permissions, but I want my application to have full control of my playlist without having to ask people to login and grant them.

Could I please have more information on whether this is possible and without having to grant permission each time? It would not interact with any other user accounts, but my own.

  1. User searches for Track ID
  2. Form obtains Track ID via API call
  3. User submits and Track ID is added to playlist ID

UPDATE:

I have since figured out how to add the track using OAuth. However, for someone else to add a track after submitting using a form (step 3), they would need to login to and accept the OAuth Permissions. Is there a way I can just set it so my code always has permission to add tracks to the playlist?

1

There are 1 best solutions below

0
On BEST ANSWER

First, you have to get a token (just like here: http://developers.deezer.com/api/explorer) if you want to create a private playlist, or just create a public collaborative playlist (so people can add tracks to your playlist).

The first thing you have to do is to create a playlist via a POST call to user/me|[your user ID]/playlist (http://developers.deezer.com/api/user/playlists) and the access token.

Then you just have to execute a POST call to /playlyst[ID of your playlist]/tracks (http://developers.deezer.com/api/playlist/tracks) to add the defined tracks.