25

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": "https://fbcdn-photos-b-a.akamaihd.net/hphotos-ak-ash3/xxxxxx4_s.jpg:

Is there any parameter that I can use to retrieve larger thumbnails? Any way to do this?

Kara
  • 6,115
  • 16
  • 50
  • 57
kakacii
  • 728
  • 3
  • 10
  • 24

7 Answers7

43

You can add custom field list for returning object.

?fields=full_picture

will return full size image.

ClockworkOrange
  • 587
  • 5
  • 10
  • the fields parameter is great, you can filter out the result to show only what you really need like: fields=full_picture,message,link,type,name,description,from – amarkovits Sep 11 '15 at 07:37
  • 1
    How to get width and height of the full_picture in the request ifself – Jagadesh Seeram Nov 05 '15 at 14:11
  • `full_picture` returns image with max width = 720p when in reality the original image can be bigger. – Jānis Jun 29 '16 at 14:13
17

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.

bighonestjohn
  • 328
  • 3
  • 8
  • This is the correct way rather than editing CDN URLs or editing "_n or _s". Great answer with example, works perfectly well with Graph API v2.3 – Never Quit May 14 '15 at 07:31
13

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.

Yawar
  • 1,924
  • 3
  • 29
  • 39
  • 1
    replacing _s with _n and _t with _b also works, but it is not a good practise. – Yawar Mar 21 '14 at 06:28
  • 1
    this is the best solution for now, thnx a lot :) – E_X Jul 28 '14 at 22:09
  • Can't find the reference in FB documentation. Any link? – tibo Nov 17 '14 at 02:58
  • You can use any Id with the in this URL for pictures [https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2], but post id didn't work because all posts don't have photos. So posts with photos have this object_id node and you can use this to get the picture. I didn't find any specific documentation about this just found out by doing hit and try. And at last this worked – Yawar Nov 17 '14 at 06:23
4

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.

RandallB
  • 5,415
  • 6
  • 34
  • 47
0

you can make a extra request with the [object_id] of the post entry

$res = $facebook->api('/yourid', 'GET', $params);
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
0

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.

Shriram
  • 155
  • 1
  • 3
  • 15
0

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

320x320

480x480

600x600

720x720