Streaming Tweets with LinqToTwitter C#

独自空忆成欢 提交于 2019-12-24 15:25:06

问题


Is it possible to get the list of tweets of a twitter user in real-time using LinqToTwitter in C#

Following is the code i use to get the tweets of a user without real-time streaming.

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

回答1:


Yes, LinqToTwitter does support streaming. See the documentation example on streaming 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();
    });


来源:https://stackoverflow.com/questions/20933029/streaming-tweets-with-linqtotwitter-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!