我正在尝试从用户的信息流中获取最后 10 篇帖子。出于某种原因,我的 FQL 查询将连续返回每个帖子中的两个。这是我的代码,请原谅 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
我不太确定为什么会这样。
最佳答案
FQL不能做group by's,而Facebook存储post stories的方式多种多样,所以有“倍数”。解决这个问题的方法是选择你需要的列,并做一个“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])
)
- 不要相信你可以做限制,你应该做小于/大于日期,或者解析和排序结果集
关于javascript - Facebook FQL 在查询中返回重复的帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10525133/