使用直到参数调用 Facebook 新闻提要(me/home),每次连续调用返回 limit/2 [英] Calling Facebook News feed (me/home) with until parameter, returns limit/2 each consecutive call

查看:23
本文介绍了使用直到参数调用 Facebook 新闻提要(me/home),每次连续调用返回 limit/2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码的精简版(没有初始化调用).一切正常,除了我每次连续调用将 until 值传入 FB.api 时,都会返回 limit/2.我曾尝试使用不同的 Facebook 帐户在通话之间等待 1 分钟,但这无济于事.

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.

我检查了返回对象中的 next 参数,该 URL 只是添加了 until 参数,其编号与我的 dataUltimoPost 完全相同.当我调用 URL 时,它也会返回一半的帖子.

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.

功能:

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);
}

调用函数:

getPost(fillPost); //returns 25
getPost(fillPost, true); //returns 12
getPost(fillPost, true); //returns 1 or 0

推荐答案

这里有一篇来自 Facebook 的博文,原因是你在要求 25 时没有得到 25 个结果.

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/

在这里,他们清楚地承认他们的 FQL 过滤机制在应用过滤之前预先限制了结果集.这是正在发生的事情的视觉效果.

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.

这篇关于使用直到参数调用 Facebook 新闻提要(me/home),每次连续调用返回 limit/2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆