如何获得具有足够权限的Facebook访问令牌来获取您标记的帖子?

sp0*_*00m 6 facebook facebook-wall facebook-graph-api oauth-2.0 facebook-access-token

您在其中标记的Facebook帖子 - 使用@Name- 会显示在您的墙上Feed中.


我的一个朋友发布了一个链接,并在其中标记了我:

启动指南


Graph API文档中,当我点击我的墙上供稿链接(Ctrl+ F:)时Profile feed,我能够看到这篇文章:

  ...
  {
     "id": "XXX",
     "from": {
        "name": "XXX",
        "id": "XXX"
     },
     "to": {
        "data": [
           {
              "name": "XXX",
              "id": "XXX"
           },
           {
              "name": "Christophe Maillard",
              "id": "XXX"
           }
        ]
     },
     "message": "The startup Guide (cc XXX, Christophe Maillard)",
     "link": "http://mashable.com/2012/06/27/startup-guide-1000-users/",
     "name": "How to Get to Your First 1,000 Users",
     "caption": "mashable.com",
     "description": "With the help of some smart marketers and entrepreneurs, we're created a clear outline for attracting your startup's first 1,000 users.",
     ...
  }
  ...
Run Code Online (Sandbox Code Playgroud)

此Feed的网址是https://graph.facebook.com/me/feed?access_token=XXX.


当复制/粘贴给定的访问令牌 - 在XXX上面的URL中替换的那个 - 在调试器中,我得到这样的东西:

访问令牌调试器

我们可以看到,访问令牌是由应用程序生成的,该应用程序Test_console使用了相当多的范围.


然后,我转到Graph API Explorer,使用Get Access Token按钮生成访问令牌,并指定调试器给我的所有范围,即Test_console应用程序用于生成其工作访问令牌的范围.最后,我me/feed通过提交GET请求来访问URL .问题:我无法看到我用浏览器标记的帖子.

我也拥有自己的应用程序,它的反应与Graph API Explorer完全相同:我也无法使用Graph API在我的墙上Feed中找到该帖子.

显然,可以使用Graph API获取您标记的帖子,因为该Test_console应用程序能够生成适当的访问令牌.但是如何为自己的应用程序获取这样的访问令牌?

Tom*_*yBs 5

您需要为您的应用授予适当的权限.在图表api explorer https://developers.facebook.com/tools/explorer?method=GET&path=me切换到您的应用程序在应用程序字段(右上角)中查看当前授予您的应用程序的权限(通过单击"再次获取访问令牌"按钮".然后确保添加正确的(我认为它是你之后的read_stream)https://developers.facebook.com/docs/authentication/permissions/