I'm trying to setup a simple app that should:
- get the client ID of an artist from its URL
- display the two latest tracks
However I'm not that practical with soundcloud and i just know basic php. I started to play with soundcloud but i wasn't able to handle it. A problem i have is that any code i write, it gets
Fatal error: Uncaught exception 'Services_Soundcloud_Invalid_Http_Response_Code_Exception' with message 'The requested URL responded with HTTP code 302.'
The easiest setup come straight from the documentation and is an example to retrieve the comments from the track id, starting from a give URL.
<?php
require_once 'Services/Soundcloud.php';
// create a client object with your app credentials
$client = new Services_Soundcloud('my_client','my_secret');
// a permalink to a track
$track_url = 'https://url_to_a_track';
// resolve track URL into track resource
$track = json_decode($client->get('resolve', array('url' => $track_url), array('CURLOPT_FOLLOWLOCATION', TRUE )));
// now that we have the track id, we can get a list of comments, for example
foreach (json_decode($client->get('tracks/' . $track->id . 'comments')) as $c)
print 'Someone said: ' . $c->body . ' at ' . $c->timestamp . "
"; ?>
Just added ('CURLOPT_FOLLOWLOCATION', TRUE
) because I've read about it around the web... And I always get the fatal error... why?