如何使用facebook graph api从页面> album-> photos->图片链接获取图片链接

时间:2016-04-28 08:02:53

标签: javascript php facebook facebook-graph-api facebook-page

我想获得任何页面的专辑,然后想要获得每张专辑的照片和照片链接 我使用下面的api路径没有得到图像网址..

为此我用过:

https://graph.facebook.com/nike/albums?access_token=my_access_token

这给了我

    {
   "data": [
      {
         "created_time": "2010-10-21T22:59:07+0000",
         "name": "Timeline Photos",
         "id": "440612488444"
      },
      {
         "created_time": "2014-11-23T01:10:20+0000",
         "name": "Nike Doernbecher Freestyle 2014 Collection",
         "id": "10152636589593445"
      },
      {
         "created_time": "2014-11-23T01:08:12+0000",
         "name": "Nike Doernbecher Freestyle 2014 Collection",
         "id": "10152636587168445"
      },
      more json....

然后从这个json我得到像 10152636589593445 的专辑ID然后使用这个网址

https://graph.facebook.com/10152636589593445/photos?access_token=my_access_token

结果是:

{
   "data": [
      {
         "created_time": "2014-11-23T01:10:27+0000",
         "name": "Chase Crouch's canvas is the Stefan Janoski Max, with the color scheme and texture inspired by Dino \u2013 Chase\u2019s constant companion during treatment. The choice of fabric was inspired by Dino\u2019s fuzzy fur, and \u201cC7\u201d stands for Chase at 7, his age when he designed this collection. The hood lining the AW77 is a rendering of Chase\u2019s last brain scan showing that his tumor is clear.\n\ngonike.me/doernbecher",
         "id": "10152636589758445"
      },
      {
         "created_time": "2014-11-23T01:11:13+0000",
         "name": "Missy Miller's canvas is the Women\u2019s Nike Free 5.0 in her favorite colors, paired with a Swoosh as bright as her personality. On each tongue are two logos: A hand icon represents the finger pricks that help Missy keep her diabetes under control, and initials to honor her sister\u2019s memory. The NYC skyline is a huge inspiration, printed on the sockliner to remind Missy that the Big Apple is at her feet, and is also on the back of the Nike Free 5.0, where Missy dreams of seeing her name in lights one day.\n\ngonike.me/doernbecher",
         "id": "10152636590298445"
      },

要生成访问令牌,我执行了此Graph API Explorer

1从应用程序中选择应用程序

  1. 从Get Token获取页面访问令牌

  2. 然后点击“扩展访问令牌”

  3. 更新

    如果我在此流程中使用其他令牌:

      从应用程序
    1. ,选择Graph API Explorer

    2. 从Get Token中选择Get User Access Token并选择manage_pages

    3. 使用此access_token,我可以获得与上面的网址链接的图片,但它只有1小时有效..是为了让它的生命时间或长时间像1年一样。?

0 个答案:

没有答案