Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API 'module' object has no attribute 'GraphAPI'

I have the following simple example in Python 2.7 (using the Anaconda distribution) for accessing data using the 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

Initially I got the 'module' object has no attribute 'GraphAPI' and noticed that the prepopulated list of methods for facebook was basically empty. This led me to take the advice of this post and uninstall facebook and install facebook-sdk. This worked in the sense that now GraphAPI shows up in the prepopulated list, but I still get the following error:

AttributeError: 'module' object has no attribute 'GraphAPI'

Is there another solution to this problem I might be overlooking?

like image 397
114 Avatar asked Apr 20 '26 16:04

114


1 Answers

This is a known Problem. Just uninstall facebook and facebook-sdk and then reinstall only facebook-sdk.

GraphApi module present in pyfacebook or not

Python Facebook SDK: 'module' object has no attribute 'GraphAPI'

Update1:

I think I got it now. I think you aren't using the token. Just try this:

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
like image 189
DevTec Avatar answered Apr 24 '26 10:04

DevTec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!