Last.fm
Code:
SocialDig({
selector: '.lastfm',
service: 'lastfm',
user: 'kjbrum',
auth: 'xxxxx'
}, function(data) {
if (data.recenttracks.track.length > 0) {
var list = document.createElement('div');
list.className = 'g g-s-2 songs';
// Loop through the songs
data.recenttracks.track.forEach(function(el, idx, arr) {
if (idx < 4) {
var item = document.createElement('div');
item.className = 'gi song';
item.innerHTML = '<a href="' + el.url + '" target="_blank"><img src="' + el.image[3]['#text'] + '"><br>' + el.name + '</a><br><small>' + el.artist['#text'] + '</small>';
// Add the new item to the list
list.appendChild(item);
}
});
// Add the list to the page
document.querySelector('.lastfm').appendChild(list);
}
});