Created
April 12, 2012 06:58
-
-
Save astronaughts/2365271 to your computer and use it in GitHub Desktop.
Python で Facebook API の fql.multi する例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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