Skip to content

soundcloud/SoundCloud-API-jQuery-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery plugin: SoundCloud oAuth 2.0 API wrapper

A simple usage example

First and most important, you'll need to get a Client ID from SoundCloud. If you haven't got one already, just register an app on the SoundCloud Apps page.

Include the plugin in your HTML code:

<script type="text/javascript" charset="utf-8" src="scripts/jquery.sc.api.js"></script>

and then, initialize it:

var api = $.sc.api('Enter your Client ID here');

or handle the successful authorization yourself:

var api = $.sc.api('Enter your Client ID here', {
  onAuthSuccess: function(user, container) {
    alert('you are SoundCloud user ' + user.username);
  }
});

also instead of passing the callbacks you can use the custom events:

var api = $.sc.api('Enter your Client ID here');
$(document).bind($.sc.api.events.AuthSuccess, function(event) {
  var user = event.user;
  // do something with the user object or call the api
  api.get('/me/tracks', function(tracks) {
    console.log(tracks);
  })
});

Please refer to the wiki for full documentation.