简体   繁体   English

Facebook非过期访问令牌

[英]Facebook non-expiring access token

I want to show the last facebook post on my website. 我想在我的网站上显示最后的facebook帖子。 I have a script for it but it needs access token to work. 我有一个脚本,但它需要访问令牌才能工作。

I followed the steps mentioned in this post: 我按照这篇文章中提到的步骤:

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

Now I've got an access token with an expiry period of 60 days but when I open https://graph.facebook.com/me/accounts , I get this error: 现在我有一个访问令牌,有效期为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
   }
}

as my access token validity is 2 months, It is supposed to work. 因为我的访问令牌有效期是2个月,它应该工作。

1: Create an application in facebook with your website url 1:使用您的网站网址在facebook中创建一个应用程序

2: Run this link in your browser 2:在浏览器中运行此链接

3: Visit the following to generate a new SHORT-LIVED (1 hour) access token: 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

4: Take that short-lived access token and send it here: 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]

5: Then, either in FB's Graph API Explorer or on your own, visit here: 5:然后,无论是在FB的Graph API Explorer中还是您自己,请访问:

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

Then paste the token and id in the code, then you will get the result. 然后将令牌和ID粘贴到代码中,然后您将获得结果。

You can debug and verify the expiration date of your token using the FaceBook Access Token Debugger: 您可以使用FaceBook访问令牌调试器调试和验证令牌的到期日期

when i'll open https://graph.facebook.com/me/accounts ... 当我打开https://graph.facebook.com/me/accounts ...

You need to open it in the Graph API Explorer and add the access token retrieved in the earlier step or append it to end of the url 您需要在Graph API Explorer中打开它并添加在前面步骤中检索到的访问令牌将其附加到URL的末尾

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM