Fab*_*n R 7 curl facebook-graph-api
我想检查一下如何处理access_token.所以,我curl用来执行以下查询:
curl -X POST https://graph.facebook.com/oauth/access_token -d "client_id=<appId>&client_secret=<secret>&grant_type=client_credentials&redirect_uri="
Run Code Online (Sandbox Code Playgroud)
它返回一个值access_token.
然后,我想得到我朋友的名单:
curl -X POST https://graph.facebook.com/me/friends -d "access_token=<token>"
Run Code Online (Sandbox Code Playgroud)
它返回此错误:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
Run Code Online (Sandbox Code Playgroud)
任何提示?
最简单的方法是使用图形 API 浏览器,前往那里并使用您的 Facebook 开发者帐户获取并访问令牌:
\n\n\n\n\n生成基本用户访问令牌
\n\n当您开始构建自己的应用程序时,您需要了解访问令牌以及如何使用 Facebook 登录生成它们,但现在,我们可以通过 Graph API Explorer 快速获取访问令牌:
\n\nRun Code Online (Sandbox Code Playgroud)\nClick on the Get Token button in the top right of the Explorer.\nChoose the option Get User Access Token.\nIn the following dialog don\'t check any boxes, just click the blue Get Access Token button.\nYou\'ll see a Facebook Login Dialog, click **OK" here to proceed.\n
您可以使用 graph api explorer 作为curl,但如果您想尝试使用真正的curl,则最新api v2.8的sintaxis如下所示:
\n\ncurl -i -H \'Authorization: Bearer YOUR_ACCES_TOKEN\' -XGET \'https://graph.facebook.com/v2.8/me\'\nRun Code Online (Sandbox Code Playgroud)\n\n就我而言:
\n\ntoni@MBP-de-Antonio \xee\x82\xb0 ~ \xee\x82\xb0 curl -i -H \'Authorization: Bearer MY-ACCES_TOKEN\' -XGET \'https://graph.facebook.com/v2.8/me\'\nHTTP/1.1 200 OK\nx-app-usage: {"call_count":2,"total_cputime":3,"total_time":3}\nExpires: Sat, 01 Jan 2000 00:00:00 GMT\nx-fb-trace-id: BnLv25AHTjq\nfacebook-api-version: v2.8\nContent-Type: application/json; charset=UTF-8\nx-fb-rev: 2929740\nCache-Control: private, no-cache, no-store, must-revalidate\nPragma: no-cache\nETag: "39875e94193dcd62dcbbf583fc0008c110820a6c"\nAccess-Control-Allow-Origin: *\nX-FB-Debug: fvO9W8Bfl+BihEy/3aZyzOiMrXOkrbK8q1I3Xk2wYnI7sSujZNC6vQzR4RoTWK7K3Hx6EdzoE2kZ/aWhsXe4OA==\nDate: Sat, 01 Apr 2017 06:55:52 GMT\nConnection: keep-alive\nContent-Length: 61\n\n{"name":"Antonio Juan Querol Giner","id":"10204458008519686"}%\nRun Code Online (Sandbox Code Playgroud)\n
您尝试过使用调试器吗?在这里调试您的访问令牌,它会告诉您有关该访问令牌的信息,以及它是否与用户绑定: https: //developers.facebook.com/tools/debug
另外,你为什么使用 POST 来获取 /me/friends ?
| 归档时间: |
|
| 查看次数: |
14609 次 |
| 最近记录: |