問題描述
根據(jù) Facebook 的 Graph API 文檔(此處),您可以通過 URL 訪問各種尺寸的用戶個人資料圖片,例如:
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
您會注意到第一個解析為以 _t.jpg(小縮略圖)結(jié)尾的 url,第二個以 _n.jpg(大圖像)結(jié)尾.到現(xiàn)在為止還挺好.同樣,我們應(yīng)該能夠像這樣查詢這些圖像:
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
后一種格式按預(yù)期工作了好幾個月,直到幾天前它突然開始完全忽略類型"參數(shù) - 現(xiàn)在一切都解析為以 _q.jpg 結(jié)尾的圖像,如果沒有,這是默認值類型"指定.結(jié)果,我再也找不到在 PHP 中查詢大圖像的方法(我的真正問題).它曾經(jīng)是這樣工作的:
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'));
...但如上所述,類型"已自發(fā)地開始被忽略.我花了幾個小時瀏覽他們的文檔,但找不到任何關(guān)于已更改內(nèi)容的參考,或者應(yīng)該完成的新"方式 - 任何指針都將不勝感激...
...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...
以下都不起作用(不返回任何內(nèi)容):
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');
基本上,由于 Facebook 幾天前出事了,似乎沒有任何方法可以從 PHP 獲取非默認圖片大小.您可以自己從 Graph API Explorer 嘗試一些調(diào)用(here).
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).
其他相關(guān)/相關(guān)鏈接:
http://stackoverflow.com/questions/2978761/facebook-graph-api-will-not-give-me-picture-data
http://stackoverflow.com/questions/7718704/requesting-picture-for-event
推薦答案
我找到了一個解決方法 - 仍然可以通過 FQL 查詢訪問各種尺寸的個人資料圖片:
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"相當于type=large" - 請參閱此處).
("pic_big" is equivalent to "type=large" - see here).
這仍然不能解釋為什么 GRAPH 調(diào)用突然中斷,或者為什么圖像大小似乎不再可以通過 Graph 訪問(我仍然想知道)......但至少有一些獲取其他尺寸照片的方法.
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.
必須喜歡 Facebook 及其一流的可靠性...
Gotta love Facebook and their top-notch reliability...
這篇關(guān)于Facebook Graph API 更改:圖片類型(大小)不再有效?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!