0

I have followed several tutorials but it seems the newest version of the Graph API broke many of them.

Here's my code:

function getAlbumImages(){
    FB.api(        
        '/760126260690750/photos',
        'GET',
        {"limit":"100",
        "access_token":"833367813443301|nDhKBT0o6K7a7j_5LMfc3QSbRNs"},
        function (response) {
           if (response && !response.error) {
               createGallery(response);
            } else
                console.log(response.error);
    });
}

function createGallery(imageJSON) {
    for (var i=0, length = imageJSON.data.length; i < length; i++){
        var image = imageJSON.data[i];
        $('body').append(image.name);
    }
};

However, nothing is appended to the body. Upon further inspection of the API call, the method /albumid/photos returns a photo object as specified by the docs, but this object does not contain anything but the ID, title and date of the photo. This is an excerpt of the data returned by my query:

{
"data": [
{
  "created_time": "2015-07-23T21:39:40+0000",
  "name": "summer is here!! #adisfrutar #relax #funnytime 💘😊🌴☀🐙🎼",
  "id": "903479883022053"
},

So clearly, the new API call does not return the image URL as it used to.

My question is then, how do I get the image URLs from the page's album so I can display a gallery on my website?

1 Answer 1

1

You need to add the image field to the url (fields=images). Example:

https://graph.facebook.com/v2.4/760126260690750/photos?access_token=833367813443301%7CnDhKBT0o6K7a7j_5LMfc3QSbRNs&fields=images,name,created_time

EDIT: If you need additional information about the photo node, check the Graph Api:

https://developers.facebook.com/docs/graph-api/reference/photo

You can see all possible parameters under the GET request.

Sign up to request clarification or add additional context in comments.

2 Comments

It is also returning the profile pictures, Is there any way we can get timeline photos?
@ShajeelAfzal You can pass album in the fields, so you know where the photos belong. Then you can easily filter. ...&fields=images,name,created_time,album

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.