Here is a slimmed down version of my code (without the initialization calls). Everything works perfectly, except that every consecutive call I make passing in an until value into FB.api, returns me limit/2. I have tried waiting as much as 1 minute in between the calls, using different Facebook accounts but it does not help the matter.
I checked the next parameter in the returned object, and the URL simply adds the until parameter with the exact same number as my dataUltimoPost. When I call the URL, it too returns half the posts.
I found other posts with inconsistent returns here and here, but none address the paging aspect directly. Coincidentally, I came across this post which uses the same logic as my code to page posts. So I think I'm on the right track.
functions:
function getPost (success, append) {
var params = { limit: 25, date_format: 'U' };
if (append)
params.until = dataUltimoPost;
FB.api('/me/home', 'get', params, function (userData) {
if (userData.data.length > 0)
dataUltimoPost = userData.data[userData.data.length - 1].created_time - 1;
success.call(this, userData.data, append);
});
};
function fillPost(posts, append) {
var postsHTML = '';
append = append === true;
alert('posts.length: ' + posts.length + ' - append: ' + append);
}
calling the functions:
getPost(fillPost); //returns 25
getPost(fillPost, true); //returns 12
getPost(fillPost, true); //returns 1 or 0