python错误:模块'对象没有属性'GraphAPI'

时间:2014-03-04 13:52:55

标签: facebook-graph-api ipython-notebook

我已经安装了pyfacebook以及python sdk,即使我收到错误如下

使用此代码时

def tweet(request):
  ACCESS_TOKEN =   'CAACEdEose0cBANsWoohRpX91cxU9iSKr64W10ukQng40cizd8kZBIedVH23dy7ORYrsajdIDfuuqvcdzsO1ullj87zzH1WAkmP0qkZAkMFGNqQVgLOpEPv3F43s9vBZCOyTQ9v7cE2m7ZAHlY3lTVqyinZAgBRjO84AC9YgQ2VQT89LA7pnbzgmgylnCuUKoEd4CTrLVZAUgZDZD'
base_url = 'https://graph.facebook.com/me'
fields = 'id,name,friends.limit(10).fields(likes.limit(10))'
url = '%s?fields=%s&access_token=%s' % \
(base_url, fields, ACCESS_TOKEN,)
print (url)
content = requests.get(url).json()
print(json.dumps(content, indent=1))
g = facebook.GraphAPI(ACCESS_TOKEN)
friends = g.get_connections("me", "friends")['data']
likes = { friend['name'] : g.get_connections(friend['id'], "likes")['data']
      for friend in friends }
print(likes)
return render_to_responce("face.html",data)

1 个答案:

答案 0 :(得分:1)

我认为你使用的是错误的facebook插件,试试facebook-sdk

sudo pip uninstall facebook
sudo pip uninstall facebook-sdk
sudo pip install facebook-sdk