通过Facebook,我需要知道,谁(哪个用户)对Facebook页面上的帖子发表了评论。 我在我的javascript文件中用facebook-batch-requests发出两个请求,第一个用于所有帖子,第二个,我想要每个帖子的请求。很高兴,如果我可以选择有一些评论的帖子。
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-request的对象。一切都是好的。但是我想要每一篇文章,而不仅仅是第一篇文章。
{
// 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 [
我几乎尝试了一切,需要你的帮助,因为我不知道如何解决这个问题。 THX!
答案 0 :(得分:0)
在Facebook batch documentation中,它声明:
请注意,出于安全原因,过滤器和脚本JSONPath构造 JSONPath表达式中不允许使用。
这可能意味着您无法使用?(@.comments.count!=0)
答案 1 :(得分:0)
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
参数设置时间范围。
我希望这有助于某人。