【问题标题】:Streaming Tweets with LinqToTwitter C#使用 LinqToTwitter C# 流式传输推文
【发布时间】:2017-09-11 13:57:46
【问题描述】:

是否可以在 C# 中使用 LinqToTwitter 实时获取 Twitter 用户的推文列表

以下是我用来在没有实时流的情况下获取用户推文的代码。

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

【问题讨论】:

    标签: c# twitter linq-to-twitter


    【解决方案1】:

    是的,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();
        });
    

    【讨论】:

    • 非常感谢,但如何告诉它只从特定帐户获取推文(例如我使用“BloombergNews”)
    • @VibeeshanRC Twitter API 使此功能仅对经过身份验证的用户可用。如果您拥有该用户的凭据,则以该用户身份进行授权。您可以在 LINQ to Twitter 网站上查看文档和下载示例:linqtotwitter.codeplex.com
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-08
    • 1970-01-01
    • 2017-09-24
    • 2020-01-16
    • 2018-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多