是否可以使用C#中的LinqToTwitter实时获取推特用户的推文列表
以下是我用来获取没有实时流媒体的用户推文的代码。
var rawTwitterItems = twitterContext.Status.Where(x => x.ScreenName == "BloombergNews" && x.Type == StatusType.User);
var items= a.ToList();
答案 0 :(得分: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();
});