Facebook 图表 API 'module' 对象没有属性 'GraphAPI'
Facebook Graph API 'module' object has no attribute 'GraphAPI'
我在 Python 2.7(使用 Anaconda 发行版)中有以下简单示例,用于使用 Facebook Graph API 访问数据:
import facebook
token = 'mytoken'
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'] for friend in friends['data']]
print friend_list
最初我得到 'module' object has no attribute 'GraphAPI' 并注意到 facebook 的预填充方法列表基本上是空的。这让我接受了 this post 的建议并卸载 facebook 并安装 facebook-sdk。这在某种意义上是有效的,现在 GraphAPI 出现在预填充列表中,但我仍然收到以下错误:
AttributeError: 'module' object has no attribute 'GraphAPI'
对于我可能忽略的这个问题,还有其他解决方案吗?
这是一个已知问题。只需卸载 facebook 和 facebook-sdk,然后仅重新安装 facebook-sdk。
GraphApi module present in pyfacebook or not
Python Facebook SDK: 'module' object has no attribute 'GraphAPI'
更新1:
我想我现在明白了。我认为您没有使用令牌。试试这个:
import facebook
token = 'mytoken'
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'] for friend in friends['data']]
print friend_list
可能很明显,但请确保您的 python 脚本没有同时命名为 facebook.py,因为它会与程序包冲突并导致此错误。
我在 Python 2.7(使用 Anaconda 发行版)中有以下简单示例,用于使用 Facebook Graph API 访问数据:
import facebook
token = 'mytoken'
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'] for friend in friends['data']]
print friend_list
最初我得到 'module' object has no attribute 'GraphAPI' 并注意到 facebook 的预填充方法列表基本上是空的。这让我接受了 this post 的建议并卸载 facebook 并安装 facebook-sdk。这在某种意义上是有效的,现在 GraphAPI 出现在预填充列表中,但我仍然收到以下错误:
AttributeError: 'module' object has no attribute 'GraphAPI'
对于我可能忽略的这个问题,还有其他解决方案吗?
这是一个已知问题。只需卸载 facebook 和 facebook-sdk,然后仅重新安装 facebook-sdk。
GraphApi module present in pyfacebook or not
Python Facebook SDK: 'module' object has no attribute 'GraphAPI'
更新1:
我想我现在明白了。我认为您没有使用令牌。试试这个:
import facebook
token = 'mytoken'
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'] for friend in friends['data']]
print friend_list
可能很明显,但请确保您的 python 脚本没有同时命名为 facebook.py,因为它会与程序包冲突并导致此错误。