Using facebook graph api how to get news feed with large picture size if the feed type is photo?

后端 未结 7 1715
说谎
说谎 2020-12-13 14:23

Using facebook graph api get News feed: https://graph.facebook.com/me/home?access_token=...

The picture field it returns is all in smallest size, like picture\": \"h

相关标签:
7条回答
  • 2020-12-13 14:33

    Even swapping _s for _l or _b might result in a larger thumbnail.
    But at times it results in invalid request or a blank image rather a white dot on a dark background.
    Ideally the api should specify crop, thumb, normal, and large (like on twitter network)with every picture object on network.

    0 讨论(0)
  • 2020-12-13 14:38

    I'm currently searching for the same thing. I know you can swap _s for _n at the end and get a larger size... but I haven't figured out how to have the api return the larger size on its own.

    0 讨论(0)
  • 2020-12-13 14:40

    You can add custom field list for returning object.

    ?fields=full_picture
    

    will return full size image.

    0 讨论(0)
  • 2020-12-13 14:41

    Along with picture field, there is an object_id field. Put this id in below url:

    https://graph.facebook.com/{object_id}/picture

    This will return actual size image. Or you can write this for different image sizes.

    https://graph.facebook.com/{object_id}/picture?type=normal

    Where type can be : thumbnail, normal, album.

    0 讨论(0)
  • 2020-12-13 14:49

    I have found that swapping the characters at the end of the file URL to _n, _b or _o no longer work.

    Facebook has released graph API 2.0 which can be used to solve this problem.

    Here is the solution:

    1. Get the object_id from the post you want the image from

    In every Post object there maybe an object_id field. This field only appears if the post has a picture of video (i.e. type = 'photo' or 'video')

    2. Make a GET request to https://graph.facebook.com/v2.0/{object_id}?access_token={token}

    e.g. if object_id = 123 and your access token = abc then the URL to call becomes https://graph.facebook.com/v2.0/123?access_token=abc

    This API call gets more information about the given object_id. Since the object_id in this case represents a photo, the response will contain the various versions of the photo.

    The response this request can be found here: https://developers.facebook.com/docs/graph-api/reference/v2.0/photo

    3. Take the largest dimensioned image from the images field

    The response from the API call has a field names images. This contains small to large sizes of the image. Just take the largest one.

    0 讨论(0)
  • 2020-12-13 14:55

    it returns the smallest size i.e., 130x130. to get the bigger size try replacing that with

    320x320

    480x480

    600x600

    720x720

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