我稍微修改了您的查询。你可以在这里试试。如果没有,请单击“获取访问令牌”。
{
"user_sex": "SELECT sex FROM user WHERE uid=me()",
"friends": "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"
}
此外,您真的不必进行多次查询。您可以使用这个(测试它):
SELECT uid,name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND not (sex in (SELECT sex FROM user WHERE uid=me())) order by name
要从您的应用程序发出请求,您应该正确编码数据。例如,对于这两个查询 url 将是:
https://graph.facebook.com/fql?q=%7B%22user_sex%22:%22SELECT%20sex%20FROM%20user%20WHERE%20uid=me()%22,%22friends%22:%22SELECT%20uid,%20name,%20sex%20FROM%20user%20WHERE%20uid%20IN%20(SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20=%20me())%20AND%20not%20(sex%20in%20(select%20sex%20from%20%23user_sex))%20%20ORDER%20BY%20name%22%7D&access_token=token
https://graph.facebook.com/fql?q=SELECT+uid,+name,+sex+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1+=+me())+AND+not+(sex+in+(SELECT+sex+FROM+user+WHERE+uid=me()))+order+by+name&access_token=token