以下の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))