Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook API and Python [closed]

Does anyone know of a good platform agnostic example or library that does Facebook authentication and Graph API access via Python?

The official Facebook Python SDK is tied to Google App Engine and Pyfacebook is deeply woven with Django.

I just want to be able to mess around in terminal and go through the process of authenticating a user and then doing simple requests from the Facebook API.

Thanks.

like image 273
super9 Avatar asked Mar 04 '11 06:03

super9


People also ask

Is Facebook Graph API deprecated?

API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.

Does Facebook have an open API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.


2 Answers

I ran across same problem some time ago and later found out that PyFacebook isn't deeply tied up with Django. It just uses a few utils from django.

My recommendation is that you setup PyFacebook alongwith django and then play around with it using command line. To use PyFacebook you won't have to go through or even know anything about django at all.

Here's an example:

from facebook import Facebook  api_key = 'Your App API Key' secret  = 'Your App Secret Key'  session_key = 'your infinite Session key of user'  fb = Facebook(api_key, secret) fb.session_key = session_key  # now use the fb object for playing around 

You might need to get an infinite session key which you can get from here: http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY

Use this code to get convert the code from above URL into infinite session key:

def generate_session_from_onetime_code(fb, code):     fb.auth_token = code     return fb.auth.getSession() print generate_session_from_onetime_code(fb, session_onetime_code) 
like image 90
sharjeel Avatar answered Sep 21 '22 19:09

sharjeel


A new library that is available is: https://github.com/semyazza/Facebook.py

It currently support authentication and the dialog API. Planned in the near future(currently being worked on) is a wrapper around the graph API.

The project goal is to be platform agnostic, single file, and use only standard Python libraries.

like image 35
Justin Weeks Avatar answered Sep 22 '22 19:09

Justin Weeks