本文介绍了使用LinqToTwitter C#流推的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用C#中的LinqToTwitter实时获取Twitter用户的推文列表
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();
推荐答案
是的,LinqToTwitter确实支持流媒体.请参见有关流式传输用户状态消息的文档示例:
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();
});
这篇关于使用LinqToTwitter C#流推的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!