Santhosh
Santhosh

Reputation: 11854

Facebook Graph API: get the photos in an album of a group

Before I ask give some information which i am already able to achieve:

  1. I'm able to get the group feed in JSON format

    • I am accessing a group. I have got a long lived access token and i could access the feed.
    • Inputs I have are: group_id, acess_token.
    • URL USED:
      https://graph.facebook.com/v2.1/{group_id}/feed?access_token={access_token}
      • The URL gave JSON formatted output of all the posts etc.
  2. I'm able to achieve the albums of the group

    • URL USED:
      https://graph.facebook.com/v2.1/{group_id}/albums?access_token={access_token}
      • The URL gave JSON formatted output of all the albums (their IDs, name, etc.).
  3. What I'm NOT able to achieve:

    • URL USED:
      https://graph.facebook.com/v2.1/{album_id}/photos?access_token={access_token}
    • URL USED:
      https://graph.facebook.com/v2.1/{album_id}?fields=photos&access_token={access_token}
    • URL USED:
      https://graph.facebook.com/v2.1/{album_id}/photos?fields=picture,source,name&type=uploaded&access_token={access_token}

      {
          "data": [
      
          ]
      }
      
    • I even tried the above in the 'Graph API Explorer', I get the same output.

    • I have tried for various group ids to see if some group ids may be the source of the problem. But I get the same output as shown above.
    • I have gone through all related questions on Stack Overflow. I am using the same URL formats as mentioned in the posts. They say that they can see the photos' data in JSON.

Upvotes: 3

Views: 1614

Answers (1)

Matthew K
Matthew K

Reputation: 993

Due to permissions restrictions it is not possible to retrieve all photos from group albums unless the user uploaded those albums themselves.

The Graph API reference mentions that one of the following is necessary to retrieve a regular album:

  • Any valid access token if the album is public.
  • A user access token user_photos permission to retrieve any albums that the session user has uploaded.

Oddly, the /{group_id}/albums edge, is undocumented. Here's what I've learned from experience about accessing group albums:

  • A user access token with user_photos permission will allow access to album information and photos for albums that user uploaded.
  • Any attempt to access any album the user did not upload (including public albums in public groups) will return album data, but not photo information.

You were using the correct queries. For completeness I will restate them here.

Album information

https://graph.facebook.com/v2.1/{group_id}/albums?access_token={access_token}

Photos

https://graph.facebook.com/v2.1/{album_id}?fields=photos&access_token={access_token}

You can still access photo attachments (but not albums) off of /{group_id}/feed

Upvotes: 3

Related Questions