2

因此,我将 Facebook 模块导入 python 以将其用于我想要创建的一些个人脚本,并最终将其链接到 Arduino。所以假设我有这样的事情:

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

这可行,但是我在这里生成的令牌会在一小时后过期。我看到 GraphAPI 类有一些扩展访问令牌的方法,但它们需要“app_id”和“app_secret”作为参数。这是怎么回事?所以我的问题是,我如何在没有 Facebook 应用程序的情况下扩展这个令牌?或者我怎样才能在没有令牌的情况下执行上面发布的操作,例如仅基于用户名和密码?

谢谢!

4

1 回答 1

0

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.

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.

See: How to extend my facebook graph API token in python?

于 2014-11-13T08:00:04.043 回答