0

I'm using this code to get a user but how do it "like" a track via a PUT request in cURL & PHP?

// build our API URL
$url = "http://api.soundcloud.com/resolve.json?"
 . "url=http://soundcloud.com/"
 . "USERNAME-HERE"
 . "&client_id=CLIENT-ID-HERE";

// Grab the contents of the URL
$user_json = file_get_contents($url);

// Decode the JSON to a PHP Object
$user = json_decode($user_json);

// Print out the User ID
echo $user->id;
Brad Fletcher
  • 3,547
  • 3
  • 27
  • 42
  • This can be helpful [Make Put with PHP](http://stackoverflow.com/questions/2153650/how-to-start-a-get-post-put-delete-request-and-judge-request-type-in-php) – Kevin Jimenez Feb 03 '17 at 11:52

1 Answers1

1

See SoundCloud API Documentation - /users.

You can favourite a track for a user with a PUT request in the following format:

/users/{user_id}/favorites/{track_id}

If you don't know how to make the cURL request, Google it - there are hundreds of tutorials and answers on StackOverflow. Here is one example:

Querying API through Curl/PHP

Community
  • 1
  • 1
BadHorsie
  • 14,135
  • 30
  • 117
  • 191