Skip to content

Instantly share code, notes, and snippets.

@astronaughts
Created April 12, 2012 06:58
Show Gist options
  • Save astronaughts/2365271 to your computer and use it in GitHub Desktop.
Save astronaughts/2365271 to your computer and use it in GitHub Desktop.
Python で Facebook API の fql.multi する例
# Facebook API なクラスのお供に。
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment