[英]How to extend Facebook access token without an app?
So i imported the Facebook module into python to use it for some personal scripts that i want to create and eventually link this to Arduino. 因此,我将Facebook模块导入python中,以将其用于一些我想创建的个人脚本,并最终将其链接到Arduino。 So let's say i have something like this: 所以说我有这样的事情:
import facebook
import codecs
token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'].encode('utf-8') for friend in friends['data']]
for i in friend_list:
print i.decode('utf-8')
This works, however the token that i am generating here expires after one hour. 这可行,但是我在这里生成的令牌在一小时后过期。 I see that the GraphAPI class has some methods for extending access tokens but they need 'app_id' and 'app_secret' as parameters. 我看到GraphAPI类具有一些扩展访问令牌的方法,但是它们需要'app_id'和'app_secret'作为参数。 What is this all about? 这是怎么回事? So my question is, how can i extend this token without a Facebook app? 所以我的问题是,如果没有Facebook应用程序,如何扩展此令牌? Or how can i do something like posted above without a token, based only on user name and password for example? 或者我该如何仅基于用户名和密码来执行上面没有令牌的内容?
Thanks! 谢谢!
I know this question is old, but I am posting in case it is helpful to anyone else since I was just struggling with something similar. 我知道这个问题很旧,但是我发帖是为了对其他人有帮助,因为我只是在努力解决类似问题。
You need a app_id & app_secret to extend the expiration. 您需要一个app_id和app_secret来延长有效期。
If you do have a fb app and want to extend the user token in python, you can extended it to 60 day expiry using the GraphAPI.extend_access_token() method. 如果您确实有一个fb应用程序,并且想要在python中扩展用户令牌,则可以使用GraphAPI.extend_access_token()方法将其扩展到60天到期。
See: How to extend my facebook graph API token in python? 请参阅: 如何在python中扩展我的facebook graph API令牌?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.