[英]facebook batch request with jsonpath
使用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}"
}
返回具有第一個后請求的對象。 萬事皆安。 但是我希望每一個帖子都這樣,而不僅僅是第一個。
{
// 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 [
我幾乎嘗試了所有事情,需要您的幫助,因為我不知道如何解決該問題。 謝謝!
在Facebook 批處理文檔中 ,它指出:
請注意,出於安全原因,JSONPath表達式中不允許使用過濾器和腳本JSONPath構造。
這可能意味着您不能使用?(@.comments.count!=0)
類的代碼?(@.comments.count!=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
參數設置時間范圍。
希望對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.