且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Facebook中获得非到期access_token?

更新时间:2023-02-20 13:11:29

对于所有投票和投票的人,我想告诉你,在这里没有明确的答案。



经过这么多的痛苦试图弄清楚FB的混乱文件,这个问题的答案是非常简单的:


  1. 将您的应用设置为本机/桌面,以便您可以获得60天的令牌(稍后将其改为永久性)。请执行以下操作:转到 https://developers.facebook.com/apps/ 编辑设置>高级>在应用程序类型中选择本机/桌面。


  2. 转到 https://developers.facebook.com/tools/explorer/ 选择您的应用程序,然后获取访问令牌


  3. 扩展权限标签中,选择 manage_pages publish_stream / p>


  4. 现在你有一个60天的临时令牌。


  5. ,请转到此处使用您的临时令牌: https://graph.facebook.com/me/accounts?access_token=REPLACE_THIS_WITH_YOUR_TEMPORARY_TOKEN


看来,您将看到永久访问令牌到您是管理员的所有Facebook页面。


I get my access token in page https://developers.facebook.com/tools/explorer and my app is able to post on a Facebook Page's wall.

However the access_token expires after an hour.

How can I get a non-expiring access_token?

Edit: Down voters: I've posted my own answer and if you read it you'll know that my solution is never found in the FB docs nor in SO.

To all those who down voted and voted for close, I want to let you know that there is no clear answer here on SO.

After so much pain trying to make sense of FB's confusing docs, the answer to this question is rather extremely simple:

  1. Set your app to Native/Desktop so you can get a 60-day token (you'll turn this to permanent later). Do this by going to https://developers.facebook.com/apps/ Edit settings > Advanced > Choose Native/Desktop in the App type.

  2. Go to https://developers.facebook.com/tools/explorer/ select your app, and Get Access Token

  3. In the Extended Permissions tab, select manage_pages and publish_stream

  4. Now you have a 60-day temporary token.

  5. To get your permanent token, go here and use your temporary token: https://graph.facebook.com/me/accounts?access_token=REPLACE_THIS_WITH_YOUR_TEMPORARY_TOKEN

Behold, you will see permanent access token to all Facebook pages which you are an admin.