2013-06-12 142 views
1

我用下面的代码赶上上我的博客一个新的Facebook评论,做出一些动作(推送数据到数据库中,并感谢用户):Facebook的评论 - fb.api评论:只返回前25点意见

<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评论。

我想这是因为默认的上限= 25 JSON

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

25个评论返回第一页。

当我有更多评论时,我的代码中的数据总是引用第25条评论。

非常感谢您的帮助。

回答