0

下面的 json 是我从服务器获得的请求 /id/albums 的响应,但我想使用该数据来获取包含所有 json 格式图片的相册的链接。提供的“链接”字段指向实际的桌面站点,但我需要 json。我将如何使用提供的 json 数据(如下)向 graph.facebook.com 发送请求,以获取相应相册中 json 格式的图片?

{
  "data": [
    {
      "id": "150228731810007",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "Profile Pictures",
      "link": "https://www.facebook.com/album.php?fbid=150228731810007&id=100004686423103&aid=1073741831",
      "cover_photo": "150228735143340",
      "count": 2,
      "type": "profile",
      "created_time": "2013-03-15T05:29:24+0000",
      "updated_time": "2013-11-09T17:12:36+0000",
      "can_upload": false
    },
    {
      "id": "233767233456156",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "Mobile Uploads",
      "link": "https://www.facebook.com/album.php?fbid=233767233456156&id=100004686423103&aid=1073741838",
      "type": "mobile",
      "created_time": "2013-11-09T17:12:30+0000",
      "updated_time": "2013-11-09T17:12:30+0000",
      "can_upload": false
    },
    {
      "id": "206255352874011",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "Aug. 17th, 2013",
      "description": "Day with some of the Family",
      "link": "https://www.facebook.com/album.php?fbid=206255352874011&id=100004686423103&aid=1073741837",
      "cover_photo": "206255402874006",
      "count": 8,
      "type": "normal",
      "created_time": "2013-08-17T21:24:12+0000",
      "updated_time": "2013-08-17T21:24:36+0000",
      "can_upload": false,
      "likes": {
        "data": [
          {
            "id": "1774907390",
            "name": "Ashley Carter"
          },
          {
            "id": "646440613",
            "name": "Mitzy Lanthier"
          },
          {
            "id": "1801948293",
            "name": "Calvin Carter"
          },
          {
            "id": "100000653918655",
            "name": "Kimberly Lane Lirette"
          }
        ],
        "paging": {
          "cursors": {
            "after": "MTAwMDAwNjUzOTE4NjU1",
            "before": "MTc3NDkwNzM5MA=="
          }
        }
      }
    },
    {
      "id": "150230918476455",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "Cover Photos",
      "link": "https://www.facebook.com/album.php?fbid=150230918476455&id=100004686423103&aid=1073741833",
      "cover_photo": "202581716574708",
      "count": 4,
      "type": "cover",
      "created_time": "2013-03-15T05:43:31+0000",
      "updated_time": "2013-08-08T17:26:35+0000",
      "can_upload": false
    },
    {
      "id": "158017154364498",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "Timeline Photos",
      "link": "https://www.facebook.com/album.php?fbid=158017154364498&id=100004686423103&aid=1073741834",
      "cover_photo": "179650435534503",
      "count": 10,
      "type": "wall",
      "created_time": "2013-04-07T14:04:04+0000",
      "updated_time": "2013-06-12T23:28:45+0000",
      "can_upload": false
    },
    {
      "id": "178309025668644",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "U.S.Navy D.E.P.",
      "description": "Was a pretty fun day. We were out there helping restore this World War 2 Destroyer.",
      "link": "https://www.facebook.com/album.php?fbid=178309025668644&id=100004686423103&aid=1073741835",
      "cover_photo": "178309055668641",
      "count": 4,
      "type": "normal",
      "created_time": "2013-06-10T00:32:45+0000",
      "updated_time": "2013-06-10T00:33:49+0000",
      "can_upload": false,
      "likes": {
        "data": [
          {
            "id": "100000651398529",
            "name": "Jennifer Manuel Hyatt"
          },
          {
            "id": "1801948293",
            "name": "Calvin Carter"
          },
          {
            "id": "1522740127",
            "name": "Bliss Reane Kinder"
          }
        ],
        "paging": {
          "cursors": {
            "after": "MTUyMjc0MDEyNw==",
            "before": "MTAwMDAwNjUxMzk4NTI5"
          }
        }
      }
    },
    {
      "id": "150228468476700",
      "from": {
        "name": "James McMahon",
        "id": "100004686423103"
      },
      "name": "Untitled Album",
      "description": "03112013",
      "link": "https://www.facebook.com/album.php?fbid=150228468476700&id=100004686423103&aid=1073741830",
      "cover_photo": "150228475143366",
      "count": 1,
      "type": "normal",
      "created_time": "2013-03-15T05:27:54+0000",
      "updated_time": "2013-03-15T05:28:17+0000",
      "can_upload": false
    }
  ],
  "paging": {
    "cursors": {
      "after": "MTUwMjI4NDY4NDc2NzAw",
      "before": "MTUwMjI4NzMxODEwMDA3"
    }
  }
}
Response received in 237 ms
4

1 回答 1

1

你有这个id字段 - 那是专辑 ID

所以,你可以自己创建链接,就像这样 -

https://graph.facebook.com/<ALBUM-ID>/photos

从中您可以获取特定相册的所有照片(但请记住,您当然需要访问令牌)

https://graph.facebook.com/<ALBUM-ID>/photos?access_token=<ACCESS-TOKEN>

于 2013-11-15T06:03:37.030 回答