udox / fb.py Goto Github PK
View Code? Open in Web Editor NEWpython sdk for facebook's both graph and rest api.
python sdk for facebook's both graph and rest api.
fb.py ================= fb.py is a software development kit for Facebook. It supports both old rest api and new graph api. it uses oauth, old style signature/secretkey based api calls for old rest api are not supported at this time. you can find official documentation at facebook about api calls and methods. 1) old rest api: http://developers.facebook.com/docs/reference/rest/ 2) graph api: http://graph.facebook.com dependencies ================= 1) python-simplejson installation ================= 1) get the archive. 2) run python setup.py install (with root priviliges) usage in Django ================= 1) create a new application in your project as "fbconnect". 2) add these lines to your settings.py FACEBOOK_CONFIG = { "login_next_url" : "%s/fbconnect/" % BASE_URL, "login_cancel_url" : "%s/fbconnect/" % BASE_URL, "login_req_perms" : 'email,publish_stream,offline_access,read_friendlists,email,user_hometown,user_location', "logout_next_url" : BASE_URL, "api_key" : "your_application_key" } 3) add to your MIDDLEWARE_CLASSES: fbpy.tools.FBPYMiddleware 4) add to your INSTALLED_APPS variable: 'fbconnect', 5) after these steps, you can call FBPY instance as request.facebook. a simple view example: if not request.facebook.is_authenticated(): return HttpResponseRedirect(request.facebook.get_login_url()) else: user_info = request.facebook.graph().get_object("me") return render_to_response("welcome.html", user_info, context_instance = RequestContext(request)) 6) read the code/wait for more documentation. fb.py is one python file with inline documentation, so browsing the code is a good idea than waiting a fully documentation. installation of "example_project" ================= 1) there is a sandbox django project in example_project directory. 2) download it and edit settings.py. (FACEBOOK_CONFIG variable.) 3) run python manage.py syncdb (we need sessions!) 4) run python manage.py runserver 5) go to your web browser, and see 127.0.0.1:8000/fbconnect low level api ================= 1) in order to send calls to new graph api, a simple request should be like that: reply = request.facebook.graph().get_object("me") 2) old rest api example: (taking mutual friends for a spesific profile id) reply = request.facebook.rest().get_object("friends.getMutualFriends", target_uid = profile_id) 3) happy hacking! to-do ================= 1) more documentation. 2) more middleware like stuff for other web frameworks in python. 3) handling cookie/session storage in FBPY. thanks ================= 1) thanks Rabia Sozkesen for finding the name of library :). 2) thanks Yilmaz Ugurlu & Timu Eren for their suggestions and ideas.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.