How to get the large picture from feed with graph api?

前端 未结 9 1641
灰色年华
灰色年华 2020-12-08 05:14

When loading the Facebook feeds from one page, if a picture exist in the feed, I want to display the large picture.

How can I get with the graph API ? T

9条回答
  •  庸人自扰
    2020-12-08 05:37

    The Graph API photo object has a picture connection (similar to that the user object has):

    “The album-sized view of the photo. […] Returns: HTTP 302 redirect to the URL of the picture.”

    So requesting https://graph.facebook.com/{object-id-from-feed}/picture will redirect you to the album-sized version of the photo immediately. (Usefull not only for displaying it in a browser, but also if f.e. you want to download the image to your server, using cURL with follow_redirect option set.)


    Edit:

    Beginning with API v2.3, the /picture edge for feed posts is deprecated.
    However, as a field the picture can still be requested – but it will be a small one.

    But full_picture is available as well.

    So /{object-id-from-feed}?fields=picture,full_picture can be used to request those, or they can be requested directly with the rest of feed data, like this /page-id/feed?fields=picture,full_picture,… (additional fields, such as message etc., must be specified the same way.)

提交回复
热议问题