Alex
Alex

Reputation: 43

Soundcloud php curl program

I have some php and javascript experience and just started learning curl. Been messing around with remote logins to soundcloud. Eventually I want be able to follow or unfollow through my program. I've been looking at the soundcloud source code and can't seem to figure out how it's processing the follow button clicks. The onclick is just set to return false.

  1. Can anyone guide me to how they process follows? I was thinking Ajax but the script appears to be something different. Is this json?
  2. Is there another specific language I need to know to effectively create this program?

Let me know what source code I can provide as the whole page seems too much to post.

Upvotes: 1

Views: 879

Answers (1)

drew010
drew010

Reputation: 69957

It appears that they have a developer API that you have access to that supports following and liking users so the best way to do what you want would be to use their API for logging in and performing actions.

If they didn't have an API, you could sniff out the requests your browser makes when you click follow and see what HTTP requests the browser makes and emulate those with cURL to get the same result. But since they have an API that is the most reliable method.

Using the PHP API code following a user is as simple as:

<?php
require_once 'Services/Soundcloud.php';

// create a client object with access token
$client = new Services_Soundcloud('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
$client->setAccessToken('YOUR_ACCESS_TOKEN');

// Follow user with ID 3207
$client->put('/me/followings/3207');

// check the status of the relationship
try {
    $client->get('/me/followings/3207');
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
    if ($e->getHttpCode() == '404')
        print "You are not following user 3207\n";
}

Upvotes: 1

Related Questions