从服务器获取用于发布到 Facebook 粉丝页面的持久令牌的步骤是什么 [英] What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server

查看:17
本文介绍了从服务器获取用于发布到 Facebook 粉丝页面的持久令牌的步骤是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Facebook 上有一个商业页面(在 Facebook 白话中称为粉丝页面).

I have a Business Page in Facebook (known as a Fan Page in Facebook vernacular).

我想在用户对我的应用执行特定操作时发布到该页面.我想以主页本身而不是用户的身份发帖(即来自我的个人帐户).该帖子将来自我的外部服务器(我使用的是 restFB).

I want to post to that Page whenever a user takes a certain action on my app. I want to post as the Page itself rather than a user (i.e. from my personal account). The post will come from my outside server (I am using restFB).

我已经完成了为我的个人帐户授予页面相应 manage_pages 权限的步骤.我还获得了该页面的访问令牌.我什至可以按照自己的意愿将页面作为页面发布到该页面.问题是我获得的令牌(通过他们的开发人员工具图形浏览器)有一个小时的到期时间.我需要它持续更长时间,最好是永远.

I have gone through the steps of authorizing my personal account with appropriate manage_pages permissions for the Page. I have also gotten an access token for the page. I have even been able to post to that page as the page as I wanted to. The problem is that the token that I get (through their developer tools graph explorer) has an expiration of an hour. I need it to last much longer than that, preferably forever.

我环顾了互联网,包括 SO 的答案,大多数帖子都指向可怕的 FB 文档,或者模糊地提到将我的外部应用程序连接到 Facebook 应用程序并通过该应用程序发布.我已经尝试完成这项工作,但坦率地说,我对整个过程感到困惑(例如,回调地址是什么?).

I've looked around the internet, including SO for the answer and most posts point back to the horrid FB docs or make vague references to hooking my outside application to a facebook application and posting through that. I've tried to make that work but I am confused by the whole process, quite frankly (what is a callback address, for example?).

无论如何,我很想看到关于获得持久访问令牌的简单英语分步说明,我可以用它从一个应用程序发布到 Facebook 粉丝页面.

Anyway, I'd love to see step by step instructions in plain English on getting a long lasting access token that I can use to post from one application to a facebook Fan Page.

请不要参考FB文档.这很糟糕.我至少经历了十几次.

Please do not refer to the FB documentation. It is terrible. I've been through it a dozen times at least.

谢谢.

推荐答案

您可以按照以下步骤为您的粉丝页面获取永不过期的令牌:

Here are some steps you can follow to get a never expiring token for your fan page:

  1. 首先,您需要获得长期存在的用户访问令牌(2 个月后到期).要获得此信息,请拨打以下电话:

  1. Firstly, you need to get the long lived user access token (that expires in 2 months). To get this, make the following call:

GET /oauth/access_token? grant_type=fb_exchange_token& client_id={app-id}& client_secret={app-secret}& fb_exchange_token={short-lived-token}

更多详情这里.如果您对此有任何困难,请告诉我.

More details here. Let me know if you had any difficulty with this.

使用您在上述步骤中获得的令牌(不是普通令牌,这是此处的主要区别)为您的页面获取永不过期的访问令牌:

Get the never expiring access token for your page using the token you obtained in the above step (not the normal token, that's the main difference here):

$facebook->api("/PAGE_ID?fields=access_token");

所以概念是,要获得长期存在的页面令牌,您应该在进行调用时使用长期存在的用户令牌.

So the concept is, to get the long lived page token you should use the long lived user token while making the call.

这篇关于从服务器获取用于发布到 Facebook 粉丝页面的持久令牌的步骤是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆