This should be fairly common but somehow I cannot get it to work. What I would like to do is the get album pictures from facebook. I am implementing this on a website.
I can get the albums using this code:
function getAlbumPhotos(){ FB.api('/me/albums', function(resp) { //Log.info('Albums', resp); var ul = document.getElementById('albums'); for (var i=0, l=resp.data.length; i<l; i++){ var album = resp.data[i], li = document.createElement('li'), a = document.createElement('a'); a.innerHTML = album.name; a.href = album.link; li.appendChild(a); ul.appendChild(li); } }); };
the resp returns a data array which contains links to the photo albums BUT I would like the image sources for each album and I don't see anything I can use in the resp data. The data object contains a link to the album but not individual images.
According to facebook documentation, photos are "connections" to albums. I am not sure what means but their doc shows that you can get individual photos.
From this link:
[http://developers.facebook.com/docs/reference/api/album/][1]
it shows the json(?) returns link, id, name, etc...which I am able to get. However, at the bottom of that page are "connections" to album which includes photos, comments, pictures. When I click on photos, it shows the JSON data structure including the img src. Question is, how do I get that? It seems so straightforward but I can't get it to work.
I tried
FB.api('/me/photos',function(resp) ...
and
FB.api('/me/photo',function(resp) ...
photos return nothing while photo returns undefine.
Code samples will be greatly appreciated.
Tap in the top right of Facebook, then tap your name. Scroll down and tap Photos. At the top of your screen, tap Albums. Tap the album you'd like to view.
Log in to your Facebook account and go to your photos or album with the photos you want to share. After opening the album with the pictures, scroll down to the bottom end of the page and click the Public Link option. Right-click the link and then select Copy.
'/me/albums'
'/'+album.id+'/picture'
'/'+album.id+'/photos'
you can also try
/_ABLUM_ID_/photos
on the graph api, i.e.
https://graph.facebook.com/12341234/photos
where 12341234 is the album object id of the album you want to get the photos of.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With