如何从流帖子中提取图像的网址

时间:2013-12-22 03:45:52

标签: facebook-fql

我想使用facebook FQL从页面流中提取帖子的图片网址,我能够得到以下内容,但是我更愿意只获得正常尺寸图片的链接,然后我计划使用java提取链接,但我想先简化结果。

FQL:

SELECT attachment   FROM stream WHERE source_id = 187050104663230  AND type = 247 AND created_time > 1383293228 LIMIT 1

上述结果:

{
  "data": [
    {
      "attachment": {
        "media": [
          {
            "href": "https://www.facebook.com/photo.php?fbid=699393523428883&set=a.190470824321158.46817.187050104663230&type=1&relevant_count=1",
            "alt": "",
            "type": "photo",
            "src": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-prn2/1508634_699393523428883_996610253_s.png",
            "photo": {
              "aid": "187050104663230_46817",
              "pid": "187050104663230_1073741857",
              "fbid": 699393523428883,
              "owner": 187050104663230,
              "index": 1,
              "width": 1024,
              "height": 393,
              "images": [
                {
                  "src": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-prn2/1508634_699393523428883_996610253_s.png",
                  "width": 130,
                  "height": 49
                },
                {
                  "src": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-prn2/s720x720/1508634_699393523428883_996610253_n.png",
                  "width": 720,
                  "height": 276
                }
              ]
            }
          }
        ],
        "name": "",
        "caption": "",
        "description": "",
        "properties": [
        ],
        "icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
        "fb_object_type": "photo",
        "fb_object_id": "187050104663230_1073741857"
      }
    }
  ]
}
Response received in 528 ms

1 个答案:

答案 0 :(得分:0)

尽可能缩小范围。

代码:

SELECT attachment.media.photo.images.src   FROM stream WHERE source_id = 187050104663230  AND type = 247 AND created_time > 1383293228 LIMIT 1

结果:

{
  "data": [
    {
      "attachment": {
        "media": [
          {
            "photo": {
              "images": [
                {
                  "src": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-prn2/1508634_699393523428883_996610253_s.png"
                },
                {
                  "src": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-prn2/s720x720/1508634_699393523428883_996610253_n.png"
                }
              ]
            }
          }
        ]
      }
    }
  ]
}