问题
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