如何使用全名获取FQL Stream

时间:2012-07-13 11:30:37

标签: facebook stream facebook-fql

我想显示来自FQL的流数据

fql?q=SELECT post_id, app_id, source_id, updated_time, created_time, filter_key,
      attribution, actor_id, target_id, message, app_data, action_links, 
      attachment, impressions, comments, likes, place, privacy, permalink, xid,
      tagged_ids, message_tags, description, description_tags, type 
      FROM stream WHERE filter_key in (
            SELECT filter_key FROM stream_filter WHERE uid=me() 
            AND type='newsfeed')

但问题是该表没有用户/页面的名称,只有ids。

有没有办法让这些结果得到名字?不仅是actor_id,还有发表评论的人的名字。

我是否需要创建多个查询并搜索流中的所有ID,然后从用户和页表中获取。然后为每一个流结果循环这些结果,看起来有点沉重。任何更简单的方法?

2 个答案:

答案 0 :(得分:3)

我不确定是否有办法一次性获取所有用户和页面,但您可以运行两个单独的查询,这些查询将返回用户/页面,然后使用两组结果执行数组合并。< / p>

用户

SELECT uid,来自uid in的用户的名字(SELECT source_id FROM stream WHERE filter_key in(SELECT filter_key FROM stream_filter WHERE uid = me()AND type ='newsfeed'))

信息页

SELECT page_id,page from page_id in(SELECT source_id FROM stream WHERE filter_key in(SELECT filter_key FROM stream_filter WHERE uid = me()AND type ='newsfeed'))

答案 1 :(得分:1)

您可以通过以下方式执行此操作:

 NSString *query =
    @"{"
    @"'friends':'SELECT post_id,actor_id,target_id,message,created_time, likes, comment_info FROM stream WHERE source_id IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND created_time > 1  ORDER BY created_time DESC LIMIT 50',"
    @"'friendinfo':'SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT actor_id FROM #friends)',"
    @"}";

获得结果后,将其存储到两个数组中:

FBFriendsNewsArray =(NSArray *) [[[result objectForKey:@"data"]objectAtIndex:0]objectForKey:@"fql_result_set"];

                              FBFriendsInfoArray=(NSArray *) [[[result objectForKey:@"data"]objectAtIndex:1]objectForKey:@"fql_result_set"];

同时在好友信息数组中显示该用户ID(actor_id)的Feed搜索。希望这会有所帮助。