我正在使用以下代码来迭代用户对其Feed所做的所有帖子:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
var fbid = response.authResponse.userID;
console.time('all posts');
var url = '/me/feed?limit=100';
var finished = false;
var c = 0, totalLikes = 0;
var timer = setInterval(function () {
if(url != '') {
console.log("Checking: " + url);
FB.api(url, function(response) {
//console.log("Got " + response.data.length + " items");
//c += response.data.length;
// calculate total likes
for(var k in response.data) {
c++;
if(response.data[k].from.id == fbid) {
console.log(response.data[k]);
}
}
if(response.paging) {
var bits = response.paging.next.split('facebook.com');
url = bits[1];
} else {
clearInterval(timer);
console.log("Found a total of " + c + " items");
console.timeEnd('all posts')
}
});
url = '';
} else {
//console.log("Skipped iteration");
}
}, 1000);
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, { scope: 'user_about_me,read_stream,user_status,user_photos,friends_about_me,user_checkins,friends_likes,user_actions.music' });
} else {
// the user isn't logged in to Facebook.
console.log("not logged in");
}
});
不幸的是,它似乎正在遍历页面,没有找到更新粘贴2011,然后在最后一页上它找到了我对2007年另一个用户的状态所做的两条评论。它遗漏了几百个我已经做过的状态更新
我花了最后三个小时研究这个,但没有用。我曾尝试过3个不同的人的帐户(所有人在2011年之前都有很多状态更新等)并且他们有相同的问题......
答案 0 :(得分:0)
您指定的网址var url = '/me/feed?limit=100';
所以它只返回前100个。您可以尝试增加限制并使用这样的偏移量:
var url = '/me/feed?limit=100&offset=101
相关api文档:https://developers.facebook.com/docs/reference/api/
进一步搜索后,似乎有一些关于历史记录的已记录错误。
https://developers.facebook.com/bugs/178108638946497?browse=search_4fabbf595050e1514377846