2014-01-05 36 views
1

是否有可能獲得在C#流的鳴叫與LinqToTwitter C#

使用LinqToTwitter繼實時Twitter用戶的鳴叫名單是我用它來獲得用戶的Twitter信息沒有實時代碼流。

var rawTwitterItems = twitterContext.Status.Where(x => x.ScreenName == "BloombergNews" && x.Type == StatusType.User); 
    var items= a.ToList(); 

回答

2

是的,LinqToTwitter支持流式傳輸。查看流users status messages文檔例如:

Console.WriteLine("\nStreamed Content: \n"); 
int count = 0; 

await 
    (from strm in twitterCtx.Streaming 
    where strm.Type == StreamingType.User 
    select strm) 
    .StartAsync(async strm => 
    { 
     string message = 
      string.IsNullOrEmpty(strm.Content) ? 
       "Keep-Alive" : strm.Content; 
     Console.WriteLine(
      (count + 1).ToString() + 
      ". " + DateTime.Now + 
      ": " + message + "\n"); 

     if (count++ == 5) 
      strm.CloseStream(); 
    }); 
+0

感謝了很多,但如何告訴,只得到從特定帳戶鳴叫(例如我使用「BloombergNews」) – VibeeshanRC

+2

@VibeeshanRC Twitter的API使得這僅適用於已通過身份驗證的用戶。如果您擁有該用戶的憑據,則以該用戶身份進行授權。您可以在LINQ to Twitter網站上查看文檔和下載示例:http://linqtotwitter.codeplex.com/。 –