2011-01-20 36 views
7

有誰知道爲什麼不管給定的圖形狀態更新對象有多少評論,它會將評論限制在25?我有一種感覺,它只返回對象上實際評論的「樣本」。我如何強制它在不使用FQL API的情況下全部獲得它們?Facebook連接圖狀態對象的評論上限爲25

+0

它根本不會在4時限制我的地雷。什麼是您的FQL查詢? – ilteris 2011-01-25 19:47:42

+0

對不起,我改變了你的下方的問題 – 2011-03-02 06:03:15

回答

1

這只是方式的圖形API的作品。看看API文檔。你一次獲得25個,並且必須通過它們。您可以使用批次中最後一個註釋的時間戳(created_time)作爲下次Graph API調用的參數,也可以使用offset參數。這是我一直在做的事情。我遇到了一些使用created_time的問題。這是我的C#測試應用程序的一個例子。忽略對PostComment對象的引用,這只是我創建的一個數據結構,用於保存我正在拖動的數據。魔術(我引用的過程)是在參數傳遞給圖形API調用:

parameters.Add("offset", numPostComments); 
parameters.Add("limit", 25); 

我相當肯定,您可以設置「限制」到什麼25歲或以下。

do 
{ 
    foreach (var comment in comments.data) 
     { 
      numPostComments++; 
      PostComment pc = new PostComment(); 
      pc.Post_ID = p.Id; 
      pc.Facebook_ID = comment.id; 
      pc.From = comment.from.name; 
      if (comment.likes != null) 
       pc.Likes = (int)comment.likes; 
      pc.CommentDate = DateTime.Parse(comment.created_time); 
      pc.CommentText = comment.message; 
      p.Comments.Add(pc); 
     } 
     // Create new Parameters object for call to API 
     Dictionary<string, object> parameters = new Dictionary<string, object>(); 
     parameters.Add("offset", numPostComments); 
     parameters.Add("limit", 25); 

     // Call the API to get the next block of 25 
     comments = client.Get(string.Format("{0}/comments", p.Facebook_ID), parameters); 
} while (comments.data.Count > 0);