Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
630 views
in Technique[技术] by (71.8m points)

php - 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...