FQL获取最后50张照片查询返回错误

时间:2013-08-30 05:49:10

标签: facebook facebook-graph-api facebook-fql

如何获取我所有朋友上传的最近50张照片?

我尝试在FQL中运行此查询:

SELECT pid, src 
FROM photo 
WHERE 
owner IN (SELECT uid1 FROM friend WHERE uid2=me())
OR pid IN (
     SELECT pid FROM photo_tag 
     WHERE subject in (SELECT uid1 FROM friend WHERE uid2=me())
) 
ORDER BY created DESC
LIMIT 50 OFFSET 0

我需要收到所有朋友的最后50张照片,或者我的朋友在哪里标记...

当我在API Explorer中运行它时出现错误:

{
  "error": "Request failed"
}

我知道我有足够的许可,因为当我运行这两个查询时,我得到了结果:

SELECT pid, src FROM photo WHERE owner =(me())

SELECT uid1 FROM friend WHERE uid2=me()

编辑: 我也试过这个..

SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified FROM photo 
WHERE owner IN  ( SELECT uid1 FROM friend WHERE uid2=me() )
and created >= 1377800559 
ORDER BY created DESC LIMIT 100

我如何获得更多信息? 是不是可以运行这样的查询?

2 个答案:

答案 0 :(得分:1)

Finnaly !!!最近发布的照片​​来自所有朋友......

SELECT pid, src, src_small, src_big, target_id, created, backdated_time 
FROM photo where pid in (
    SELECT attachment.media.photo.pid
    FROM stream 
    WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me()) AND type = 247
)

你可以看到我最初的做法是错的...... 它实际上需要使用stream表来获取最新的帖子.. 然后它可以被过滤以仅发布照片并使用他们的pid来获取所有必需的信息! YAY!

我希望它可以帮助遇到同样问题的其他人。

答案 1 :(得分:0)

我不确定为什么,但这里发生了一件奇怪的事情。当我尝试你的查询时 - 我得到了

  

请求失败

然后,在挖掘了一下之后,我用ID替换了SELECT uid2 FROM friend WHERE uid1 = me()并且查询工作正常!

因此,作为一种解决方案,您可以先尝试获取朋友列表:

SELECT uid2 FROM friend WHERE uid1 = me()

然后在查询中使用此结果为 -

SELECT pid, src 
FROM photo 
WHERE 
  owner IN (ID1, ID2, ID3 ...)
  OR pid IN (
     SELECT pid FROM photo_tag 
     WHERE subject IN (ID1, ID2, ID3 ...)
  ) 
ORDER BY created DESC
LIMIT 50 OFFSET 0

很奇怪,但是这会起作用!