对于Facebook,我需要知道谁(哪个用户)在facebook页面上评论了一篇帖子。我在javascript文件中使用facebook-batch-request发出了两个请求,第一个是针对所有post,第二个是每个post的请求。很高兴有,如果我可以选择只有一些评论的帖子。
FB.api('/', 'POST', {
batch: [
{
// all posts from page from last year
'method': 'GET',
'name': 'posts_page_year',
'omit_response_on_success': false,
'relative_url': fbPageID + '/posts?since=2012-01-01&until=' + timeNow + '&limit=200000'
},
{
// all post-ids from last year
'method': 'GET',
"relative_url": "/{result=posts_page_year:$.data.*.id[?(@.comments.count!=0)]}"
}
]
}, function(response) {
callback(response);
}
);我的问题是第二个批处理请求,它返回一个错误(#803)。我试过一点。
{
// all post-ids from last year
'method': 'GET',
"relative_url": "/{result=posts_page_year:$.data.0.id}"
}返回具有第一个post请求的对象。一切都很好。但我希望每个帖子都是这样的,而不仅仅是第一篇。
{
// all post-ids from last year
'method': 'GET',
"relative_url": "/{result=posts_page_year:$.data.*.id}"
}返回错误(#803)您请求的某些别名不存在以及所有ID的列表。
{
// all post-ids from last year
'method': 'GET',
"relative_url": "/{result=posts_page_year:$.data.*.id[?(@.comments.count!=0)]}"
}返回此错误:(#803)您请求的某些别名不存在:{result=posts_page_year:$.data.*.id[
我几乎什么都试过了,需要你的帮助,因为我不知道如何解决这个问题。谢谢!
发布于 2013-07-13 23:17:58
在Facebook的batch documentation中,它声明:
请注意,出于安全原因,JSONPath表达式中不允许使用筛选器和脚本JSONPath构造。
这可能意味着您不能使用像?(@.comments.count!=0)这样的代码
发布于 2014-10-27 15:41:04
FB.api('/', 'POST', {
batch: [
{
// 0: all likes from user
'method': 'GET',
'relative_url': 'me/likes'
},
{
// 1: all user-posts from last month
'method': 'GET',
'relative_url': 'me/posts?since=' + timeMonthAgo + '&until=' + timeNow + '&limit=200000'
},
{
// 2: all user-posts from last year
'method': 'GET',
'relative_url': 'me/posts?since=' + timeYearAgo + '&until=' + timeNow + '&limit=200000'
}
]
}, function (response) {
callback(response);
}
);我必须设置一个限制,这样每个响应现在都有一个内容限制。可以将限制设置为不可能的大数字。您还必须使用since和until参数设置时间范围。
我希望这对某些人有帮助。
https://stackoverflow.com/questions/15792247
复制相似问题