5

我需要获取按喜欢排序的 FB 用户的照片。我通过 Facebook JavaScript SDK 运行了这个 FQL 查询来获取它们:

SELECT object_id, src_big, src_big_width, src_big_height, link, like_info, caption, created 
FROM photo 
WHERE owner = MANY_PICS_USER_ID ORDER BY like_info DESC LIMIT 10

对于拥有超过 3000 张照片的用户,查询失败。原来有很多这样的用户。相关的 Facebook 错误在这里http://developers.facebook.com/bugs/438568326189781

注意:删除“ORDER BY like_info”使查询工作,但我没有简单的方法来获取这些图片,按喜欢排序

重现:
选择一个至少有 3000 张照片的 FB 朋友,获取他们的用户 ID,然后在 API GRAPH EXPLORER 中运行上述查询(替换 MANY_PICS_USER_ID)。

最好的解决方法是什么?或者,您能推荐最简单的轻量级 Open Graph 解决方案吗?

4

1 回答 1

2

To sort photos by likes you need the following:

Which return the following data structure:

"data": [
{
  "id": "1234567890", 
  "source": "http://photo.url.in.facebook.cdn.com/", 
  "created_time": "2012-09-13T22:52:34+0000", 
  "likes": {
    "data": [
      {
        "id": "1234567890", 
        "name": "Full Name"
      }, 
      .....
    "paging": {
      "next": "https://graph.facebook.com/1234567890/likes?limit=25&offset=25"
    }
  }
},
{
  "id": "312323232323", 
  "source": "PICTURE_URL", 
  "created_time": "2012-09-12T20:54:27+0000", 
  "likes": {
    "data": [..]
  }
},
....
"paging": {
  "previous": "http://PREVIOUS_URL?fields=id,source,name,height,width,link,likes&limit=100&since=123456", 
  "next": "http://NEXT_URL?fields=id,source,name,height,width,link,likes&limit=100&until=234567"
}
  • If total number of pictures is more than 100, run all next queries, from the "next" link until the num of pics will be less then 100.

  • For every picture you need to count total number of likes. If the number of likes is more than 25, run extra query from likes.paging.next until number of likes will be < 25 and get the total quantity.

  • Sort all those pics by number of likes.

So for the user with 3000 pics it will be in total 30 calls + extra calls for each picture with more than 25 likes.

于 2012-10-23T00:45:08.703 回答