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

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)'));


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)

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...


Need Your Help

.htaccess: FilterProvider issue

javascript json .htaccess

this is probably really simple, but my coder is on holiday and out of comms and I'm a graphic designer with fairly basic HTML and CSS knowledge. This is beyond me.

PDO : How different is mysql from postgresql

php mysql postgresql pdo

I want to use Mysql on my local and PostgreSQL on production server. How difficult is it. I am mysql novice and have no idea on PostgreSQL. I will be using just crud with joins. My coding is in PHP...