【问题标题】:I have a list of Facebook user ids. Is there a way I can easily download them? [closed]我有一个 Facebook 用户 ID 列表。有没有办法可以轻松下载它们? [关闭]
【发布时间】:2013-04-29 21:39:48
【问题描述】:

我目前将它们保存在 Excel 电子表格中。我知道我可以一个一个地得到它们 (Facebook graph API: ID of user profile picture),但是有没有办法一次得到它们?

【问题讨论】:

    标签: facebook facebook-graph-api profile image


    【解决方案1】:

    为了下载图像,您需要向每个 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));
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多