1

I can't find a recent answer on this.

Tweetsharp reportedly in a number of old posts does not support streaming from the Twitter user stream api. However github shows a class which looks like it does support streaming.

https://github.com/danielcrenna/tweetsharp/blob/cad16546df7c5be6ee528ecfa6171098b662a6ab/src/net40/TweetSharp.Next/Service/TwitterService.Streaming.cs

Does tweetsharp now supports streaming from Twitter, where it did not before

I'm learning c# and I'd appreciate the view of an experienced coder before i continue to spend hours working with tweetsharp.

Damo
  • 1,898
  • 7
  • 38
  • 58

1 Answers1

5

If what you search for is only Twitter's streaming API, you can implement it without a need for an external library

JavaScriptSerializer serializer = new JavaScriptSerializer();

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://stream.twitter.com/1/statuses/sample.json"); 
webRequest.Credentials = new NetworkCredential("...", "...");
webRequest.Timeout = -1;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

StreamReader responseStream = new StreamReader(webResponse.GetResponseStream());
while (true)
{
    var line = responseStream.ReadLine();
    if (String.IsNullOrEmpty(line)) continue;

    dynamic obj = serializer.Deserialize<Dictionary<string, object>>(line);

    if(obj["user"]!=null) 
        Console.WriteLine(obj["user"]["screen_name"] + ": " +  obj["text"]);

}
L.B
  • 114,136
  • 19
  • 178
  • 224
  • 1
    why would you `obj["user"]["screen_name"]` instead of `obj.user.screen_name` when using dynamic? – bevacqua Mar 20 '12 at 01:36
  • I was starting to consider this. Thanks for the example, ill try it out. – Damo Mar 20 '12 at 18:49
  • Unfortunately, things aren't so simple anymore. v1.1 of the API is required, and uses OAuth only. Does anyone know where to find a status/sample.json reader in C# that uses OAuth? – MikeB Jun 29 '13 at 02:14