有效获取大型Facebook照片

时间:2016-04-03 20:39:36

标签: android facebook image facebook-graph-api

我在Android上使用Facebook SDK版本2.5,并希望访问用户的照片。因此我使用user_photos权限和照片边缘。基本上检索图像不是问题。这可以通过Graph API调用

完成
me/photos?fields=images.

返回例如

{
  "data": [
    {
      "images": [
        {
          "height": 1200,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xpl1/t31.0-8/12748066_10153276753262102_6141720567752387908_o.jpg",
          "width": 1600
        },
        {
          "height": 960,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xpl1/t31.0-8/p960x960/12748066_10153276753262102_6141720567752387908_o.jpg",
          "width": 1280
        },
        {
          "height": 720,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xlf1/v/t1.0-9/12729304_10153276753262102_6141720567752387908_n.jpg?oh=0405c0dddc0ce13f7d5ce646a7866041&oe=5787E738",
          "width": 960
        },
        {
          "height": 600,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xpl1/t31.0-0/p600x600/12748066_10153276753262102_6141720567752387908_o.jpg",
          "width": 800
        },
        {
          "height": 480,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xlf1/v/t1.0-0/p480x480/12729304_10153276753262102_6141720567752387908_n.jpg?oh=8e5c785d88737d275f1958bffd8e28d5&oe=5787B2CD",
          "width": 640
        },
        {
          "height": 320,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xlf1/v/t1.0-0/p320x320/12729304_10153276753262102_6141720567752387908_n.jpg?oh=bd747db36d52794abd65b3865149d827&oe=57BC3F8F",
          "width": 426
        },
        {
          "height": 540,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xpl1/t31.0-0/p180x540/12748066_10153276753262102_6141720567752387908_o.jpg",
          "width": 720
        },
        {
          "height": 130,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xlf1/v/t1.0-0/p130x130/12729304_10153276753262102_6141720567752387908_n.jpg?oh=67dfa35a5be1c78a8b2c2823f06e917e&oe=577D1D9F",
          "width": 173
        },
        {
          "height": 225,
          "source": "https://scontent.xx.fbcdn.net/hphotos-xlf1/v/t1.0-0/p75x225/12729304_10153276753262102_6141720567752387908_n.jpg?oh=474198feca51172b40b62893fdcca398&oe=57BD1929",
          "width": 300
        }
      ]
     // other stuff
    }
  ]
   // other stuff
}.

这可能没问题,但信息太多(特别是在收到100张照片时)。我只需要一个尺寸的所有图像,所以我尝试限制图像数组中包含的信息。不幸的是,我所获得的只是通过此调用排除了高度和宽度信息:

me/photos?fields=images.fields(source).

无论如何,仍然有一个图像的所有尺寸。在我看来,从Facebook收到的信息仍然太多,我没有使用。所以我基本上想要的是一个Graph API调用来获取大量图像并最小化接收到的未使用信息。我只需要每张图片一个尺寸,比如

me/photos?fields=images.limit(1)

但不幸的是,此调用不会限制图像数组。有谁知道如何解决?

0 个答案:

没有答案