从服务器发送到Facebook粉丝专栏的步骤如何获得持久的令牌 [英] What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server

查看:197
本文介绍了从服务器发送到Facebook粉丝专栏的步骤如何获得持久的令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Facebook上有一个商业页面(被称为Facebook本地的粉丝专页)。



我想要发布到该页面每当用户对我的应用程序采取某些措施。我想作为页面本身而不是用户(即从我的个人帐户)发布。该帖子将来自我的外部服务器(我正在使用restFB)。



我已经完成了使用适当的 manage_pages授权我的个人帐户的步骤页面的权限。我也获得了页面的访问令牌。我甚至已经能够以页面的形式发布到该页面。问题是我得到的令牌(通过他们的开发工具图形资源管理器)已经过了一个小时。我需要它比这更长久,最好是永远。



我已经看过互联网,包括SO的答案和大多数帖子指向可怕的FB将我的外部应用程序挂起到Facebook应用程序并发布。我试图做这个工作,但是整个过程都很困惑,坦白说(例如什么是回调地址?)。



无论如何, d喜欢在中获得一个简单的英文的逐步说明,获得一个持久的访问令牌,我可以使用它从一个应用程序发布到Facebook粉丝页面。



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



谢谢。

解决方案

以下是您可以按照以下2个步骤获得粉丝专页永不过期的令牌:


  1. 首先,您需要获得长期使用的访问令牌(在2个月内到期)。要获得这个,请进行以下调用:

      GET / oauth / access_token? grant_type = fb_exchange_token&安培; CLIENT_ID = {应用ID}&安培; client_secret = {应用秘密}&安培; fb_exchange_token = {short-lived-token} 

    更多详细信息 here 。如果您发现任何困难,请告知我。


  2. 使用您在上述步骤中获得的令牌获取页面永不过期的访问令牌(不是正常的标记,这里的主要区别) -

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


所以概念是:长期使用的页面令牌,您可以在拨打电话时使用长寿命的usrr令牌。


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

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).

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.

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?).

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.

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

Thank you.

解决方案

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

  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 found any difficulty with this.

  2. Get the never expiring access token for your page using the token you obtained in the above step(not the normal token, thats the main difference here)-

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

So the concept is that: to get the long lived page token you should use the long lived usrr token while making the call.

这篇关于从服务器发送到Facebook粉丝专栏的步骤如何获得持久的令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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