0

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
Community
  • 1
  • 1
mateuscb
  • 10,150
  • 3
  • 52
  • 76

1 Answers1

1

Here's a blog post from Facebook themselves for the reason why you don't get back 25 results when asking for 25.

http://developers.facebook.com/blog/post/478/

Here they've clearly admitted that their FQL filtering mechanism pre-limits the result set BEFORE applying filtering. Here's a visual on what's happening.

enter image description here

DMCS
  • 31,720
  • 14
  • 71
  • 104
  • Thanks for the link, I had read this article as well. The problem however is that its no limiting me based on filters. but doing something strange when using until/limit. For example, if i set limit to 25 and execute the code I receive the following counts 25,12,7,0; for a total 44. But if I set the limit to 11, I receive 11, 11, 9 for a total of 31. So, if it were simply filtering, I should have received the same totals. Correct? – mateuscb Jun 05 '12 at 19:56
  • Facebook acknowledges searching via their API is not up to the normal way of doing things. Knowing filtering and limiting happens in the wrong order, you can quickly see where the #s can become off. Image if many of the excluded results was at the beginning of the result set. So it may appear to you the results starts at 5/1, when in actual results really were started at 4/26, but it lopped off things early. Querying with different limits will yield different results. Hell, even the exact same query ran x number of times can result in different # of results (well documented on stackoverflow). – DMCS Jun 05 '12 at 22:19
  • Understand, still feel that something is wrong when using the limits with until. Specifically as stated in my example that by diminishing the limit value, I get a different total. On a side note, as inconsistent as it may be, the first time I call it, I always get my limit. – mateuscb Jun 06 '12 at 15:26
  • Yes, something is very wrong with it. See the blog article where Facebook publicly admits to having a faulty, non-standard way of filtering and limiting their result sets. It's all right there in that blog article. – DMCS Jun 07 '12 at 20:08