Warm tip: This article is reproduced from stackoverflow.com, please click
facebook-graph-api facebook

Automate Facebook page access token generation

发布于 2020-03-31 22:58:26

So I'm trying to obtain a list of posts from a Facebook page that I have created. After reading the documentation, I need to provide a user access token / page token to each API request in order to get the data. The documentation states that the user access tokens & page access tokens come in two variants:

  • Short life, expires within a few hours / days.
  • Long life, expires within 90 days.

The application I am building is a aggregated news (Facebook, twitter and Instagram) feed that will be displayed to users on my website.

From what I have read, the app tokens don't have an expiration but cannot access the pages API.

Do Facebook really expect application owners to remember to manually update their keys every 90 days in order to keep the applications working, or am I missing something that I can do to automate this?

Questioner
Kieran Devlin
Viewed
38
luschn 2020-01-31 20:21

If it is only about your Page, you are not missing anything, and there is no way to automate generating tokens - that would make expiration dates pointless. You can only send yourself a reminder before it expires. But: It can also expire if your change your Facebook Password, for example. It would be a good idea to implement a proper error handling so you get a message when the Token does not work anymore.

If it is about other Pages too, you can apply for Page Public Content Access and use an App Token that is valid forever.