2012-05-03 27 views
0

根据这个:http://developers.facebook.com/docs/reference/api/batch,有一种方法可以使用第一个查询的结果来填充第二个查询。如何通过Graph api在单个批量查询中获取Facebook页面帖子及其评论?

curl \ 
    -F 'access_token=...' \ 
    -F 'batch=[{ "method": "GET", \ 
       "name" : "get-friends", \ 
       "relative_url": "me/friends?limit=5", \ 
       }, \ 
       { "method": "GET", \ 
       "relative_url": "?ids={result=get-friends:$.data.*.id}" \ 
       }]' \ 
     https://graph.facebook.com 

不过,我想在第一个查询页面的帖子,然后拿到个人文章的评论。不知道这是否可能,任何帮助表示赞赏。

curl \ 
    -F 'access_token=...' \ 
    -F 'batch=[{ "method": "GET", \ 
       "name" : "get-posts", \ 
       "relative_url": "cocacola/posts?limit=5", \ 
       }, \ 
       { "method": "GET", \ 
       "relative_url": "?????" \ 
       }]' \ 
     https://graph.facebook.com 

回答

0

幸运的是,Facebook允许多个对象在一个单一的查询,如果您使用/comments?ids

curl \ 
    -F 'access_token=...' \ 
    -F 'batch=[{ "method": "GET", \ 
       "name" : "get-posts", \ 
       "relative_url": "cocacola/posts?limit=5", \ 
       }, \ 
       { "method": "GET", \ 
       "relative_url": "/comments?ids={result=get-posts:$.data.*.id}" \ 
       }]' \ 
     https://graph.facebook.com 

不幸的是,这是比在平行做5次个人的查询慢。

相关问题