Facebook非过期访问令牌

use*_*882 7 facebook token

我想在我的网站上显示最后的facebook帖子.我有一个脚本,但它需要访问令牌才能工作.

我按照这篇文章中提到的步骤:

https://neosmart-stream.de/de/facebook/how-to-create-a-facebook-access-token/comment-page-1/#comment-617

现在我有一个访问令牌,有效期为60天但是当我打开https://graph.facebook.com/me/accounts时,我收到此错误:

{
   "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)

因为我的访问令牌有效期是2个月,它应该工作.

Tap*_*eak 7

1:使用您的网站网址在facebook中创建一个应用程序

2:在浏览器中运行此链接

3:访问以下内容以生成新的SHORT-LIVED(1小时)访问令牌:

https://www.facebook.com?client_id=[APPID]&client_secret=[APPSECRET]&redirect_uri[http://APPURL]&scope=manage_pages,read_stream&response_type=token
Run Code Online (Sandbox Code Playgroud)

4:获取该短期访问令牌并将其发送到此处:

https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&client_secret=[APP_SECRET]&grant_type=fb_exchange_token&fb_exchange_token=[EXISTING_ACCESS_TOKEN]
Run Code Online (Sandbox Code Playgroud)

5:然后,无论是在FB的Graph API Explorer中还是您自己,请访问:

https://graph.facebook.com/me/accounts?access_token=[TOKEN]

然后将令牌和ID粘贴到代码中,然后您将获得结果.

您可以使用FaceBook访问令牌调试器调试和验证令牌的到期日期:


phw*_*hwd 1

当我打开https://graph.facebook.com/me/accounts时...

您需要在 Graph API Explorer 中打开它并添加在前面步骤中检索到的访问令牌将其附加到 url 末尾

https://graph.facebook.com/me/accounts?access_token=XXXX