FQL multiquery python

时间:2016-03-18 12:25:03

标签: facebook python-3.x fql.multiquery

您好我试图在python 3中运行FQL多重查询并且失败了。我可以运行1个查询,但是当我尝试运行多个查询时,我无法使其运行。为了这个问题,我只使用了我在网上找到的多种查询。

import urllib.request
import urllib.parse
ACCESS_TOKEN = 'xxxxxxxxxxxxxxxxx'


query1 = "SELECT sex FROM user WHERE uid=me()"
query2 = "SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND not (sex in (select sex from #user_sex))  ORDER BY name"
query = {'query1':query1,'query2':query2}

params = urllib.parse.urlencode({'q': query, 'access_token': ACCESS_TOKEN})
#print (params)

url = "https://graph.facebook.com/fql?" + params
print (url)
data = urllib.request.urlopen(url).read()
print(data)

1 个答案:

答案 0 :(得分:0)

正如@CBroe所说,再使用FQL是没有意义的......你可以使用Graph API一次性获取这些信息:

GET /me?fields=gender,friends{id,name,gender}

请注意,您的朋友也需要使用该应用,否则您将无法检索他们的信息。