Jason Robinson
Jason Robinson

Reputation: 81

Favoriting a private track via SoundCloud API

Does anyone know how to favorite a track that is private using the SoundCloud API?

This is what I have so far.

SC.put('/me/favorites/1234567', function(track,error){alert(error.message)})

This works for the track when it's public, but when its private I'm getting a 404/401 error.

Upvotes: 1

Views: 243

Answers (1)

Paul Osman
Paul Osman

Reputation: 4117

As long as you have access to the private track, you should be able to favorite it. Note that this means that either:

  1. The track belongs to the currently authenticated user or..
  2. The track was explicitly shared to the currently authenticated user

As long as either of those two conditions is met, you will be able to favorite a track. Note that of course you also must allow the user to authenticate first:

SC.initialize({
  client_id: 'foo',
  redirect_uri: 'http://example.com/callback.html'
});

SC.connect(function(me) {
  SC.put('/me/favorites/53919056', function(response, error) {
    // response.status will equal "201 - Created"
  });
});

Upvotes: 1

Related Questions