Python
Facebook

Python で Facebook API の fql.multi する例

More than 5 years have passed since last update.

Facebook API なクラスのお供にどうぞ。


fql_multi.py


import urllib
import simplejson

def fql_multi(self, access_token, **queries):
args = {
'queries': simplejson.dumps(queries),
'format': 'json',
'access_token': access_token
}
contents = urllib.urlopen('https://api.facebook.com/method/fql.multiquery?' + urllib.urlencode(args))
return simplejson.loads(contents.read())

result_sets = fql_multi(
'ACCESS_TOKEN',
q1 = 'SELECT post_id, created_time FROM stream WHERE source_id = me()',
q2 = 'SELECT user_id FROM like WHERE post_id in (SELECT post_id FROM #q1)',
q3 = 'SELECT fromid FROM comment WHERE post_id in (SELECT post_id FROM #q1)',
)

print result_sets