Lenny Domnitser’s
domnit.org

⇙ Jump to content

explicit

Tiny Python Facebook library

As promised,

tinyface.py

It needs Python and simplejson. Here’s how you use it:

>>> import tinyface
>>> app = tinyface.App('...', '...')
>>> session = app.rpc('auth.getSession', auth_token='...')
>>> app.rpc('users.getInfo', uids='8112822',
            fields='first_name',
            session_key=session['session_key'])
[{u'first_name': u'Lenny', u'uid': 8112822}]
>>> my_events = app.fql('''select name from event
                where eid in (select eid from event_member
                where uid = 8112822)''',
                        session_key=session['session_key'])

It just provides two methods, rpc and fql. The latter is a shortcut for FQL. However, all Facebook API calls, including FQL, can be made through rpc, which takes the method name and any parameters. method, api_key, v, call_id, format, and sig are put in automatically by the code, so the caller has to provide any parameters besides those.

Simple, huh? It’s BSD-licensed. You can use it as a module or just drop it into a script.