facebook access token is invalid - trying to post to facebook website-“page” via app using a cron

拈花ヽ惹草 提交于 2019-11-28 01:47:00
IMB

This question is very similar to my own question and I've spent 2 days trying to solve this. The solution is super 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

You should see permanent access token to all Facebook pages which you are an admin

See https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal/ - specifically Scenario 5 -

  1. Use the server-side Oauth flow (see the Login docs for details) to obtain the access token for the page admin (which has manage_pages permission)

  2. Retrieve the Page Access token you retrieve from /me/accounts or /<PAGE ID>?fields=access_token.

This Page access token will have infinite expiry, meaning it won't expire unless unless the user stops being an admin of the page, removes your app, kills all their app sessions, etc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!