2014-03-04 87 views
0

我已經使用這個代碼時安裝pyfacebook以及蟒蛇SDK甚至我得到的錯誤如下蟒蛇錯誤:模塊」對象有沒有屬性‘GraphAPI’

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

我想你正在使用錯誤的facebook插件,請嘗試facebook-sdk

sudo pip uninstall facebook 
sudo pip uninstall facebook-sdk 
sudo pip install facebook-sdk 
相關問題