Facebook Graph API: Get post/status attached photos

可紊 提交于 2019-11-29 00:02:31

I was looking for a solution for this as well and actually just found it.

The Facebook Platform changelog says the following:

/v2.1/{post-id} will now return all photos attached to the post: In previous versions of the API only the first photo was returned with a post. This removes the need to use FQL to get all a post's photos.

With this knowledge I went to the Graph Api Explorer and found a post that had 2 attachments or more added to it.

After finding the post, and with that the post id, I tried the request Facebook told me to do:

/v2.1/{post_id}

This does NOT give you the desired result. The nice thing about the explorer is that you can search for fields you want to add to your request.

You want to add the attachments (plural) field. NOTE: It might be that the graph api explorer only shows the attachment (singular) field. This is NOT right.

So, to summarize:

  1. Get the post id of the post containing the images.
  2. Create a new request to the graph api that looks something like: /v2.1/{post_id}?fields=attachments

Then read the result to get your desired attachments.

I hope this helps you out as I have been struggling for a while as well.

KR

PS: This is tested with a user and not a group, but it should be basically the same.
PS2: This is just an explanation of how you get attachments of a single post. You can also add the attachments field to the /me/home egde to immediately get all attachments at every post like so:

me/home?fields=message,from,attachments

PS3: The permissions you need are

  1. user_status
  2. read_stream
  3. user_photos
  4. user_videos

Facebook is not very clear on this matter and it is very hard to figure things out like this. So I hope this will help everyone that is searching for this solution.

Eridana

I answered for the same question here : /v2.1/{post-id} does not deliver photos

It seems it's a Facebook bug. My colleague opened an issue. Here's the link: https://developers.facebook.com/bugs/762280800482269/
You also can find some info here:
https://developers.facebook.com/bugs/790976317600139/
Hope it will help you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!