Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API Change: Picture type (size) no longer working?

According to Facebook's Graph API documentation (here), you can access various sizes of a user's profile picture through URLs such as:

https://graph.facebook.com/(userid)/picture?type=small
https://graph.facebook.com/(userid)/picture?type=large

You'll notice that the first resolves to a url ending in _t.jpg (the small thumbnail) and the second ending in _n.jpg (the large image). So far so good. Equivalently, we should be able to query for these images like this:

https://graph.facebook.com/(userid)?fields=picture&type=small
https://graph.facebook.com/(userid)?fields=picture&type=large

This latter format worked as expected for many months, until just a few days ago when it suddenly started ignoring the "type" parameter entirely - everything now resolves to an image ending in _q.jpg, which is the default if no "type" is specified. As a result, I can no longer figure out a way to query for the large image in PHP (my real problem). It used to work like this:

$pic = $facebook->api('/me', array('fields' => 'picture', 'type' => 'large'));

...but as described above, "type" has spontaneously started being ignored. I've spent several hours scouring their documentation but haven't been able to find any reference to what has changed, or the "new" way this should be done - any pointers would be hugely appreciated...

EDIT:

None of the following work, either (returns nothing):

$pic = $facebook->api('/me/picture', array('type' => 'large'));
$pic = $facebook->api('/(my_uid)/picture', array('type' => 'large'));
$pic = $facebook->api('/me/picture/?type=large');
$pic = $facebook->api('/(my_uid)/picture/?type=large');

Basically, since Facebook broke things a few days ago there doesn't seem to be any way to get a non-default picture size from PHP. You can try out some of the calls yourself from the Graph API Explorer (here).

Other related/relevant links:

http://stackoverflow.com/questions/2978761/facebook-graph-api-will-not-give-me-picture-data
http://stackoverflow.com/questions/7718704/requesting-picture-for-event
like image 285
Metal450 Avatar asked Aug 16 '12 07:08

Metal450


People also ask

How do I update my Facebook Graph API?

In the App Dashboard Settings > Advanced, scroll to the Upgrade API Version section.

Is Facebook Graph API RESTful?

Is Facebook Graph API a REST API? The Legacy REST API is in the process of being deprecated, while the Graph API is the most current, so if you're unsure of which one to use, your best bet is to go with that one. As you suggested, the Graph API, just like the Legacy REST API, is in fact a RESTful API.

What 3 terms does Facebook use to describe what the graph API is composed of?

The Graph API is named after the idea of a "social graph" — a representation of the information on Facebook. It's composed of nodes, edges, and fields.

How do I make a graph API on Facebook?

Go to Tools – Graph API Explorer to generate Access Tokens for various kinds of API that you would like to use in your app. Choose the app and kind of token you need in the drop down menus in the left part of the screen. Then click “Generate Access Token”.


3 Answers

You must request the API with the field_expansion syntax

These api requests works :

$results = $facebook->api('/me', array('fields' => 'picture.height(300).width(300)'));

$results = $facebook->api('/me', array('fields' => 'picture.type(large)'));

like image 168
VLoppez Avatar answered Nov 13 '22 00:11

VLoppez


As described in this bug on Facebook, you can request this via the new API "field expansion" syntax.

This works for me:

https://graph.facebook.com/____OBJECT_ID____?fields=picture.type(large)
like image 26
thaddeusmt Avatar answered Nov 13 '22 01:11

thaddeusmt


I found a workaround - profile pictures of various sizes can still be accessed via an FQL query:

$pic = $facebook->api(array('method'=>'fql.query', 'query'=>"SELECT pic_big FROM user WHERE uid=$fb_uid"));

("pic_big" is equivalent to "type=large" - see here).

This still doesn't explain why the GRAPH call suddenly broke though, or why image sizes don't seem to be accessible via Graph at all anymore (which I'd still like to know)...but at least there's some way to get the other size photos.

Gotta love Facebook and their top-notch reliability...

like image 29
Metal450 Avatar answered Nov 13 '22 01:11

Metal450