Facebook Graph API: Get post/status attached photos

后端 未结 2 1779
长情又很酷
长情又很酷 2020-12-15 12:15

How can one get multiple attachments of a post/status in a group?

For example: A group status that some member wrote and added multiple photos to..

Currently

相关标签:
2条回答
  • 2020-12-15 12:44

    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.

    0 讨论(0)
  • 2020-12-15 12:55

    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.

    0 讨论(0)
提交回复
热议问题