使用FQL时出现意外行为

时间:2012-08-06 23:54:23

标签: facebook limit facebook-fql

向FQL添加LIMIT选项会导致返回比没有LIMIT更多的结果。 举个例子:

SELECT post_id, actor_id, message,description,type FROM stream WHERE source_id = me()

返回4个结果:

{ "data": [
{
  "post_id": "1458319848_4164228991531", 
  "actor_id": 1458319848, 
  "message": "Oh happy days!", 
  "description": null, 
  "type": 46
}, 
{
  "post_id": "1458319848_4081409841104", 
  "actor_id": 1458319848, 
  "message": "", 
  "description": "Caroline Natan and Or Karlinsky are now friends.", 
  "type": null
}, 
{
  "post_id": "1458319848_4076275592751", 
  "actor_id": 1458319848, 
  "message": "", 
  "description": "Caroline Natan changed her Interested In.", 
  "type": null
}, 
{
  "post_id": "1458319848_4075703458448", 
  "actor_id": 100001179537125, 
  "message": "", 
  "description": null, 
  "type": 237
}]}

但是使用:

SELECT post_id, actor_id, message,description,type FROM stream WHERE source_id = me() LIMIT 9

返回 5 结果:

{"data": [
{
  "post_id": "1458319848_4164228991531", 
  "actor_id": 1458319848, 
  "message": "Oh happy days!", 
  "description": null, 
  "type": 46
}, 
{
  "post_id": "1458319848_4081409841104", 
  "actor_id": 1458319848, 
  "message": "", 
  "description": "Caroline Natan and Or Karlinsky are now friends.", 
  "type": null
}, 
{
  "post_id": "1458319848_4076275592751", 
  "actor_id": 1458319848, 
  "message": "", 
  "description": "Caroline Natan changed her Interested In.", 
  "type": null
}, 
{
  "post_id": "1458319848_4075703458448", 
  "actor_id": 100001179537125, 
  "message": "", 
  "description": null, 
  "type": 237
}, 
{
  "post_id": "1458319848_4069875152744", 
  "actor_id": 100000876758120, 
  "message": "", 
  "description": null, 
  "type": 237
}]}

当然这不会有任何意义! 我在这里错过了什么吗?如果是的话,什么?我也读过this,我没有看到有关这里描述的问题的任何内容。

提前致谢。

1 个答案:

答案 0 :(得分:1)

您链接的文章实际上解决了此问题:

  

您可能会注意到返回的结果数量并不总是等于指定的“限制”。这是预期的行为。在检查查看返回的结果是否对查看者可见之前,查询参数应用于我们的结尾。因此,您可能会得到比预期更少的结果。

这基本上意味着facebook在执行查询后会过滤结果。

在您的示例中,在第一个查询中,有一个隐式限制,例如5.在这5个结果中,1由于可见性限制而被过滤掉,您得到4。 在第二个查询中,服务器获得10个结果,根据可见性筛选出5个结果,并向您返回5。