从下面的 FQL 查询中,我可以获取我的新闻源上包含“www.youtube.com”的帖子的 actor_id 和附件数据。但是,我还希望能够获得该用户的图片和姓名。我如何将其合并到以下查询中?
SELECT created_time, post_id, actor_id, type, updated_time, attachment
FROM stream
WHERE post_id IN
(SELECT post_id
FROM stream
WHERE ('video') IN attachment
AND source_id IN
(SELECT uid2
FROM friend
WHERE uid1=me())
LIMIT 100)
编辑:
#right fql query, but prints only part of it
posts_query = "SELECT created_time, post_id, actor_id, type, updated_time, attachment FROM stream WHERE post_id in (select post_id from stream where ('video') in attachment AND source_id IN ( SELECT uid2 FROM friend WHERE uid1=me()) limit 100)"
fql_var = "https://api.facebook.com/method/fql.query?access_token=" + token['access_token'] + "&query=" + posts_query + "&format=json"
data = urllib.urlopen(fql_var)
fb_stream = json.loads(data.read())
#print ast.literal_eval(json.dumps(fb_stream))
users_query = "SELECT uid, first_name FROM user WHERE uid IN (SELECT actor_id FROM (" + posts_query+"))"
fqlquery_user = "https://api.facebook.com/method/fql.query?access_token=" + token['access_token'] + "&query=" + users_query + "&format=json"
user_data2 = urllib.urlopen(fqlquery_user)
user_stream2 = json.loads(user_data2.read())
print ast.literal_eval(json.dumps(user_stream2))