1

我想显示来自 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')

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

有什么方法可以为这些结果命名吗?不仅是actor_id,还有发表评论的人的名字。

我是否需要对流中的所有这些 id 进行多查询和搜索,然后从用户表和页表中获取。然后为每个流结果循环这些结果,似乎有点重。有更简单的方法吗?

4

2 回答 2

3

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

用户

SELECT uid,name from user where 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,name from page where page_id in (SELECT source_id FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed')

于 2012-07-13T13:57:16.650 回答
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 搜索时。希望这会有所帮助。

于 2013-05-08T08:06:44.187 回答