从Facebook帖子中获取多张照片

时间:2018-08-18 13:37:08

标签: facebook facebook-graph-api

我现在正在使用Facebook的Graph API,并且试图将我正在管理的页面上的Facebook帖子复制到另一个地方。

到目前为止,我设法成功获取了messagefull_picture,问题始于帖子中包含多张图片,好像我从帖子中得到的图片都不多。

Graph API reference for posts仅讲述了为一张图片或全图片返回一个链接,而我却没有提到要获得尽可能多的图片。

有什么办法从帖子中获取所有图片?

1 个答案:

答案 0 :(得分:1)

您可以通过附件获取它们,至少对于我发表的帖子而言

$ okurl https://graph.facebook.com/v3.1/10153937378849343_10156680000194343/attachments
{
  "data": [
    {
      "subattachments": {
        "data": [
          {
            "media": {
              "image": {
                "height": 540,
                "src": "https://scontent.xx.fbcdn.net/v/t1.0-0/p180x540/xxx_n.jpg",
                "width": 720
              }
            },
            "target": {
              "id": "10156680000094343",
              "url": "https://www.facebook.com/photo.php?fbid=xxx"
            },
            "type": "photo",
            "url": "https://www.facebook.com/photo.php?fbid=xxx"
          },
          {
            "media": {
              "image": {
                "height": 540,
                "src": "https://scontent.xx.fbcdn.net/v/t1.0-0/p180x540/38918411_10156680000119343_5451882299853373440_n.jpg?_nc_cat=0&oh=ac71357254bb90e14e4a658531ff370b&oe=5C08C9C2",
                "width": 720
              }
            },
            "target": {
              "id": "10156680000109343",
              "url": "https://www.facebook.com/photo.php?fbid=xxx"
            },
            "type": "photo",
            "url": "https://www.facebook.com/photo.php?fbid=xxx"
          }
        ]
      },
      "target": {
        "id": "10156680000194343",
        "url": "https://www.facebook.com/542634342/posts/10156680000194343/"
      },
      "title": "Photos from My post",
      "type": "album",
      "url": "https://www.facebook.com/542634342/posts/10156680000194343/"
    }
  ]
}