Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Facebook API Data with Python

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

I'm new to the Facebook Graph API. Doing some research, in the past people used pyfacebook and the Facebook Python SDK, but it seems neither are being updated / supported anymore. What are people currently using to access the data? Is there one that's independent of a platform / framework?

like image 307
Bonnie Yu MSFT Avatar asked May 27 '12 23:05

Bonnie Yu MSFT


1 Answers

People use SDKs. It's the most manageable way to do it.

The Python SDK (facebook) is up to date and has a repo at https://github.com/pythonforfacebook/facebook-sdk. It's not official because Facebook doesn't officially support anymore but it is maintained (last commit 12 days ago) and people do use it.

facepy as well is actively maintained https://github.com/jgorset/facepy. facepy's interface is very hands on and is a light wrapper on the API (pretty much you have access to the raw API) where as Python SDK is more integrated.

For example,

Photo Upload

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')
)

Notice the .put_photo vs me/photos of which the latter resembles the native Graph API call.

Also there is Django Facebook http://django-facebook.readthedocs.org/en/latest/

like image 100
phwd Avatar answered Oct 12 '22 13:10

phwd