Access Facebook API data using Python

What is the best library to access Facebook Graph API data for python 2.7 or python 3.0?

I am new to Facebook Graph API. Having done some research, in the past people used the pyfacebook and Facebook SDK for Python, but it doesn't seem to be updated and supported. What do people currently use to access data? Is there one that is platform / structure independent?

+7
source share
1 answer

People use the SDK. This is the most manageable way to do this.

The Python SDK (facebook) is updated and has a repo at https://github.com/pythonforfacebook/facebook-sdk . It is not official because Facebook is not officially supported, but it is supported (last completed 12 days ago), and people use it.

facepy is also actively supported by https://github.com/jgorset/facepy . the facepy interface is very user-friendly and is a lightweight API shell (to a large extent, you have access to a raw API), where the Python SDK is more integrated.

For example,

Upload photos

Python SDK

graph = facebook.GraphAPI(oauth_access_token) tags = json.dumps([{'x':50, 'y':50, tag_uid:12345}, {'x':10, 'y':60, tag_text:'a turtle'}]) graph.put_photo(open('img.jpg'), 'Look at this cool photo!', album_id_or_None, tags=tags) 

Facepy

 graph = GraphAPI(oauth_access_token) graph.post( path = 'me/photos', source = open('parrot.jpg') ) 

Pay attention to .put_photo vs me/photos , of which the latter resembles the Graph API native call.

There is also Django Facebook http://django-facebook.readthedocs.org/en/latest/

+8
source

All Articles