扩展Facebook打开图表令牌以发布到页面

问题描述:

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

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

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

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.

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

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.

当您(管理员用户)进行身份验证时,您可以获得页面访问令牌。页面令牌基于您的短命令用户令牌。为了获得长寿命的页面令牌,您需要获得一个长久的用户令牌。他们通常持续大约两个月。

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. 获取一个短命的用户令牌

  2. 获取您的应用程序ID和应用程序密码。

  3. 进行以下GET调用: code> https://graph.facebook.com/oauth/access_token&grant_type=fb_exchange_token&client_id= {应用ID}&安培; client_secret = {应用秘密}&安培; fb_exchange_token = {短命令牌} 。

  4. 现在使用从步骤3返回的令牌来创建一个新的长寿命页面令牌。

  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.