Skip to content

Instantly share code, notes, and snippets.

@matths
Created May 22, 2012 20:06
Show Gist options
  • Save matths/2771311 to your computer and use it in GitHub Desktop.
Save matths/2771311 to your computer and use it in GitHub Desktop.
grab user's facebook album cover pictures
// don't forget to set &oauth=1 in FB.init
// check for valid login, the easy way:
if (FB._authResponse != null)
FB.login(function(r) {}, {scope: 'user_photos'})
FB.api('/me/albums', function(d) {
for (var i=0; i<d.data.length; i++) {
console.log(d.data[i].id, d.data[i].name, d.data[i].link);
// type: thumbnail, small, album
$('body').prepend('<img src="https://graph.facebook.com/'+d.data[i].id+'/picture?type=thumbnail&access_token='+FB._authResponse.accessToken+'">');
}
});
var albumId = 000000000;
FB.api('/'+albumId+'/photos/', function(d) {
for (var i=0; i<d.data.length; i++) {
console.log(d.data[i].id, d.data[i].source, d.data[i].picture);
$('body').prepend('<img src="'+d.data[i].picture+'">');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment