Facebook API and Python [closed]

℡╲_俬逩灬. 提交于 2019-11-30 10:26:44

问题


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.


回答1:


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)



回答2:


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.




回答3:


How about taking the Facebook Python SDk itself and stripping off the GAE part from it and using the other API calls only?



来源:https://stackoverflow.com/questions/5190346/facebook-api-and-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!