长期存在的Facebook令牌

时间:2014-07-11 22:16:47

标签: facebook facebook-graph-api

我在过去的几个小时内努力获得60天的有效令牌。我在Facebook上创建了一个不公开的测试应用程序。原因很明显,因为它什么也没做。

我提出了一个请求:

  

https://graph.facebook.com/v2.0/oauth/access_token?grant_type=fb_exchange_token&client_id= {应用ID}&安培; client_secret = {应用秘密}&安培; fb_exchange_token = {用户60分钟-有效令牌}

我收到了这个回复:

  

{u' error':{u' message':u'访问令牌不属于应用程序1234287494356751',u' code':1 ,你输入':你' OAuthException'}}

我需要持久令牌来查询图表api一些感兴趣的粉丝页面,有没有办法为此目的或其他方式获取它?我在Debug部分检查了用户访问令牌,但仍然有效。

1 个答案:

答案 0 :(得分:1)

我制作了一个Python脚本来解决我使用库facepy(https://github.com/jgorset/facepy)的问题:

from facepy import get_extended_access_token
from facepy import GraphAPI

application_id=''
application_secret=''
app_access_token='app_id|....' #https://developers.facebook.com/tools/accesstoken/
user_token='' #generated from the https://developers.facebook.com/tools/accesstoken/
long_lived_access_token, expires_at = get_extended_access_token(user_token,
    application_id, application_secret)

print long_lived_access_token+' '+str(expires_at)

输出:

  

some_long_token 2014-09-10 01:10:04.384503

如果有人知道如何用卷曲/请求做同样的事情,我会很高兴知道它。