1

我使用下面的代码在我的博客上捕获新的 facebook 评论,并进行一些操作(将数据推送到数据库并感谢用户):

<script type='text/javascript' src='//connect.facebook.net/en_US/all.js'></script>
        <script type="text/javascript">
        FB.Event.subscribe('comment.create', function(a) {       
        FB.api('comments', {'ids': a.href}, function(res) {
        var ufb_message = '';
        var ufb_from = '';
        var ufb_name = '';
        var ufb_jump = false;
        var testJSON = res[a.href].comments.data;
        var i=0;
        while(i < testJSON.length) {
        try{
        var tempJSON = testJSON[i].comments.data.pop();
        if (testJSON[i].comments.count > 0 && tempJSON.id == a.commentID) {
        ufb_message = tempJSON.message;
        ufb_from = tempJSON.from['id'];
        ufb_name = tempJSON.from['name'];
        ufb_time = tempJSON.created_time;
        i=testJSON.length;
        ufb_jump = true;
        }
        } catch(e) {}       
        i++;
        }
        if(!ufb_jump) {
        var data = res[a.href].comments.data.pop();
        ufb_message = data.message;
        ufb_from = data.from.id;
        ufb_name = data.from.name;
        }
        alert('Thanks for your comment!' + ufb_name);
        <?php
        [...] php code to execute [...]
        ?>
        });
        });
        </script>

如果评论 < 25 则一切正常。从第 26 条评论返回的数据总是关于第 25 条评论。

我想这是因为 json 中的默认限制 = 25

体育: https ://graph.facebook.com/comments/?ids=http://www.isocial.it/aggiornamento-ios-7-beta-iphone

返回包含 25 条评论的第一页。

当我有更多评论时,我的代码中捕获的数据总是参考第 25 条评论。

非常感谢您的帮助。

4

1 回答 1

0

在您的数据末尾,应该有一个“分页”参数,这将返回更多您的评论。请参阅https://developers.facebook.com/docs/reference/api/pagination/

于 2013-06-12T22:48:08.093 回答