During the last week I made some improvements to the SoundCloud AS3 API library:
- Full ASDoc documentation is now available online
- Uploaded an example file for Flash CS4
- API is now prepared for scenarios where you want to automatically get an access token after authentication (I’ll do an extra post on this in the next days)
- Added support for requests to public resources without having to authenticate first
I should say a few words about the last point: If you want to build a simple audio player app like Citysounds (check it out, great stuff!) that only accesses public resources, chances are you don’t have to deal with OAuth authentication at all.
For example, the code to access the public tracks of a specific SoundCloud user looks like this:
var scClient:SoundcloudClient = new SoundcloudClient();
var delegate:SoundcloudDelegate = scClient.sendRequest("users/anyUserName/tracks", "GET");
delegate.addEventListener(SoundcloudEvent.REQUEST_COMPLETE, requestCompleteHandler);
protected function requestCompleteHandler(event:SoundcloudEvent):void
{
var trackList:XML = event.data as XML;
trace(trackList);
}
This will give you a list of tracks in XML format with all properties like track title, URL and so on. You can then pick a track from the list and start playing the MP3 with the Sound class. Yes, it’s that simple! ;)
But as soon as you want to access private tracks or want to do write operations like updating a user profile or uploading a track, you’ll need to go through the OAuth authentication process. Check the Quickstart Tutorial to see how this works.
3 Comments
Hi! I’ve been trying to create a flash based uploader for Soundcloud for my Rails application. I’ve run into an issue that perhaps you can assist with – first, I’m hitting their API directly so I can avoid having to upload first to my server and then push to SC. The problem I’ve encountered is that even after a successful upload, I am unable to retrieve the response Content-Location header data. Is this even possible? I need to get this link so that i can store it in the app…
Also – I can’t download the API Wrapper from github! seems to be broken…
Hi Praveen, github is having some trouble generating the ZIP files lately. I have uploaded the current sources to the download section so you can grab them there:
http://github.com/dasflash/Soundcloud-AS3-API/downloads
Regarding the link to the uploaded file: you can retrieve it from the response body of the upload, I think it is in a property named “permalink-url”