Skip to content

Instantly share code, notes, and snippets.

@cponeill
Created April 3, 2016 04:07
Show Gist options
  • Save cponeill/9b94e8f1ce901801139cea0ba5fb8abb to your computer and use it in GitHub Desktop.
Save cponeill/9b94e8f1ce901801139cea0ba5fb8abb to your computer and use it in GitHub Desktop.
// Call client ID.
// Be sure to add your personal api client key
SC.initialize({
client_id: '<client_id>'
});
// Loop through tradck data and append SC embed.
function makeCenterFromTracks(tracks) {
var track, permURL, newDiv;
for (var i = 0; i <= 10; i++) {
newDiv = document.createElement("center");
newDiv.id = "track" + i;
track=tracks[i];
SC.oEmbed(track.permalink_url,{color:"ff0066",
maxwidth:750, maxheight: 166},newDiv);
document.body.appendChild(newDiv);
}
}
$(document).ready(function() {
$('#search').click(function() {as
// assign user variable to input name
var user = $('input[name=Soundcloud]').val();
// get SC data and append results into html page.
SC.get('/users/'+user+'/tracks', {limit: 100}, function(tracks) {
$('#results').append(makeCenterFromTracks(tracks));
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment