【发布时间】:2013-04-29 21:39:48
【问题描述】:
我目前将它们保存在 Excel 电子表格中。我知道我可以一个一个地得到它们 (Facebook graph API: ID of user profile picture),但是有没有办法一次得到它们?
【问题讨论】:
标签: facebook facebook-graph-api profile image
我目前将它们保存在 Excel 电子表格中。我知道我可以一个一个地得到它们 (Facebook graph API: ID of user profile picture),但是有没有办法一次得到它们?
【问题讨论】:
标签: facebook facebook-graph-api profile image
为了下载图像,您需要向每个 URL 发出请求。但是,您将能够在一个请求中获得所有 URL 的列表。您可以为此使用 FQL 语句:
SELEXT pic_big FROM user WHERE uid IN (UID1,UID2,...)
你会得到类似这样的回应:
{
"data": [
{
"pic_big": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/xxx.jpg"
},
{
"pic_big": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/yyy.jpg"
},
...
]
}
以 PHP 为例,您可以遍历结果并使用 file_get_contents() 和 file_put_contents() 的组合来下载图像:
$imageData = json_decode($fqlResult,true);
foreach($imageData['data'] AS $key => $value){
file_put_contents('/new/path/to/image',file_get_contents($value));
}
【讨论】: