Skip to content

Instantly share code, notes, and snippets.

@midoooo
Forked from hasantayyar/fbgetalbumphotos.js
Created November 17, 2015 23:14
Show Gist options
  • Save midoooo/532c20c90b8550be65ad to your computer and use it in GitHub Desktop.
Save midoooo/532c20c90b8550be65ad to your computer and use it in GitHub Desktop.
Get Facebook Albums and Album Photos
function getAlbumPhotos(albumid){
FB.api("/"+albumid+"/photos",function(response){
var photos = response["data"];
var html = "count "+photos.length;
for(var i=0;i<photos.length;i++) {
var images = photos[i]["images"];
html+= "Photo "+(v+1);
html+= '<img src="'+images[(images.length-1)]["source"]+'" />';
var tmp = "";
for(var j = 0 ;j<images.length;j++) {
tmp+= '<a href="'+images[j]["source"]+'"> size : '+images[j]["width"]+"X"+images[j]["height"]+'</a><br />';
}
html+=temp+"<hr />";
}
document.getElementById("photos").innerHTML = html;
});
}
function getAlbums(){
document.getElementById("albums").innerHTML="yukleniyor...";
FB.api('/me/albums', function(resp) {
var html="<ul>";
for (var i=0, l=resp.data.length; i<l; i++){
var album = resp.data[i];
html+= '<li><a href="#" onclick="getAlbumPhotos(\''+album.id+'\')">get photos</a> <a href="'+album.link+'">'+album.name+'</a><li>';
}
html+="</ul>";
document.getElementById("albums").innerHTML=html;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment