This project has moved and is read-only. For the latest updates, please go here.

Parse a status line from userstream

Feb 21, 2013 at 9:56 PM
Hi Joe,
I'm trying to use UserStreamParser for L2T but it's got a little outdated. It uses the following line of code to create a new status that doesn't work:
this.Status = Status.CreateStatus(SerializationHelper.JsonToXml(json));
Note that the parameter type of the JsonToXml is string (the response line is passed to it).
so the question is what is the replacement for the CreateStatus method and how can I parse the response into status using the L2T methods.

Feb 25, 2013 at 8:45 AM

LINQ to Twitter originally used XML, but I saw the writing on the wall and converted everything to Json. Now, Twitter API v1.1 only supports Json, so that kind of worked out. I haven't built a stream parser, partially because one existed, but I can see that doesn't work anymore. That said, I gave each of the entities a constructor that took a parameter of type JsonData, which is a type that belongs to the LitJson library that I've included in LINQ to Twitter. Each of the IRequestProcessors convert the JsonData to entities this way. Here's a quick example with Status:
            JsonData statusJson = JsonMapper.ToObject(responseJson);
            var status = new Status(statusJson);
The responseJson is the JSON string that Twitter returns in their response.

Feb 25, 2013 at 9:36 AM
Works fine, Thanks Joe.
It's a good idea to integrate stream parsers to L2Q.
One more thing, in SampleStream sample it's says it's required to pass username and password to the streams, doesn't L2Q support oauth yet ? I think I read somewhere on Twitter that it streams support oauth and also basic auth is becoming deprecated.
Feb 25, 2013 at 3:05 PM
UserStream and SiteStream use OAuth, but I do need to move the rest of the streams to OAuth. BTW, I recently replied to another post of someone who was planning to update the stream parser project.

Mar 3, 2013 at 8:22 PM
I updated it locally very quickly. I'm not 100% confident that what I wrote works. I also am not sure I like the event pattern over a straight callback method, so I'm not actually using it myself, yet.

Why doesn't the streaming API have better entity type markers!? I've seen quite a variety of different ways of determining what kind of data is in a message as I've been looking through various Twitter API libraries. Would be way simpler if they'd just tell us what kind of thing each message is upfront :(.
Mar 4, 2013 at 4:26 PM
I was thinking along the same lines about entity type markers and decided to post a question on the Twitter Developer Discussion forum:

Something I had overlooked is the Streaming Message Types.

Mar 5, 2013 at 2:01 AM
+1'd you :). "historical reasons" is a mighty strong motivator, though.