Forked from mager/spotify-apps-sandbox-Facebook_get_listening_history.js
Created
March 13, 2013 17:27
-
-
Save jrthib/5154305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Instantiate the global sp object; include models & views */ | |
var sp = getSpotifyApi(1); | |
var auth = sp.require('sp://import/scripts/api/auth'); | |
var permissions = ['user_actions.music']; | |
var app_id = '126891607432106'; | |
var request_url = 'https://graph.facebook.com/me/music.listens'; | |
auth.authenticateWithFacebook(app_id, permissions, { | |
onSuccess : function(accessToken, ttl) { | |
var url = request_url + '?access_token=' + accessToken; | |
$.getJSON(url, function(data) { | |
var listens = data.data; | |
for(var i=0;i<listens.length;i++) { | |
var tracklink = listens[i].data.song.url; | |
var trackname = listens[i].data.song.title; | |
$('#listens').append('<li><a href="' + tracklink + '">' + trackname + '</a></li>'); | |
} | |
}); | |
}, | |
onFailure : function(error) { | |
console.log("Authentication failed with error: " + error); | |
}, | |
onComplete : function() { } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment