扩展Facebook Open Graph令牌以发布到页面

扩展Facebook Open Graph令牌以发布到页面

问题描述:

I'm using this tutorial (from the first answer on that page).

In short it uses a FB app, and PHP CURL GET to post to your Facebook page via HTTP. I have it working and can post to my page (as my page) with the correct token.

However, the page access token only lasts an hour, meaning you have to constantly re-authorize by generating a new token. How can I set-and-forget, or otherwise extend my token? I have read the facebook documentation but can't apply it to my scenario.

I just want to authorise once, receive a token and have my web form be able to post to my page.

我正在使用本教程(来自该页面的第一个答案)。 p>

简而言之 使用FB应用程序和PHP CURL GET通过HTTP发布到您的Facebook页面。 我有它工作,可以使用正确的令牌发布到我的页面(作为我的页面)。 p>

但是,页面访问令牌只持续一个小时,这意味着你必须不断重新授权 通过生成新令牌。 如何设置 - 忘记或以其他方式扩展我的令牌? 我已经阅读了facebook文档,但无法将其应用到我的场景中。 p>

我只想授权一次,接收令牌并让我的网络表单能够发布到我的页面。 p> div>

You get your page access token when you (the admin user) authenticate. The page token is based on your short-lived user token. In order to get a long-lived page token you need to get a long-lived user token. They usually last around two months.

Here's how you get a long-lived page token.

  1. Get a short-lived user token.
  2. Get your app ID and app secret.
  3. Make the following GET call: https://graph.facebook.com/oauth/access_token&grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-token}.
  4. Now use the token returned from step 3 to create a new long-lived page token.

The & symbol should be replaced with ? (question mark). Then it should work.

ex:

https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-token}