Facebook FQL在查询中返回重复的帖子

时间:2012-05-09 22:39:39

标签: javascript facebook coffeescript facebook-fql

我正在尝试从用户的流中获取最后10个帖子。出于某种原因,我的FQL查询将连续返回每个帖子中的两个。这是我的代码,Pardon the CoffeeScript,

method = 'fql.multiquery'
queries = 'feed' : "SELECT attachment , type , created_time , filter_key,     actor_id, description, message  FROM stream WHERE (filter_key = 'others' OR filter_key = 'owner') ORDER BY created_time DESC LIMIT 10"
params =
    method : method
    queries : queries
FB.api (params) , (response) =>
    #and so on

我不确定为什么会这样。

1 个答案:

答案 0 :(得分:2)

FQL不能分组,而Facebook以各种方式存储帖子故事,因此有“倍数”。解决这个问题的方法是选择你需要的列,并在“where in”中限制你的结果集,即:

select 
    attachment , type , created_time , filter_key, actor_id, description, message
FROM 
   stream
WHERE 
   post_id in (select post_id 
      FROM 
         stream 
     WHERE 
          (filter_key = 'others' OR filter_key = 'owner' and created_time < [long-ass unix time])
  )
  • 不相信你可以做限制,你应该做小于/大于日期,或解析和排序结果集
相关问题