Note that there are some explanatory texts on larger screens.

plurals
  1. POtwitter continuous stream asp.net c#
    text
    copied!<p>This is my first post on stack overflow, but I have been using it for a long time. I would like to begin by saying thanks for the great community of developers who have helped me solve many problems as an undergrad student.</p> <p>Now, I have been working on an asp.net project in which I want to get a twitter stream on a specific query (e.g. Star Trek), and always show a scrolling list of the last 10 or so tweets about it. I am also using a sentiment scorer and I want to show the scoring result for each tweet, probably next to the tweet itself. </p> <p>So far, I have been able to create a simple console application in which I connect to the streaming api with the appropriate OAuth header and parse the json into a nice readable format. However, I now want to create an asp.net application like the one mentioned above. Many examples show how to do simple posts, or get the last 20 statuses from a user, and update the page with those by returning a view, but none of these examples show how to deal with twitter's continuous/infinite stream.</p> <p>My question is how do I relay the twitter stream in asp.net from a controller? Is it possible to return a view every time a new status comes into the stream? Or am I going in a completely wrong direction? I have also read about PushStreamContent - is it possible to relay the twitter stream using this method, and then possibly make an ajax call? I feel like that isn't the most simple solution. I also doubt I need to use threads.</p> <p>I am very new to asp.net mvc, and perhaps mvc is not the best way of solving my problem. However, I would like to use it if I can. Any tips, methods, or help steering me in the right direction would be greatly appreciated. I hope this question is clear and specific enough.</p> <p>Here is some example code of my TwitterStream class:</p> <pre><code>public void StartStream() { try { HttpWebRequest request = MakeRequest(); //makes oauth request HttpWebResponse resp = (HttpWebResponse)request.GetResponse(); sReader = new StreamReader( resp.GetResponseStream() ); while(true) { PopulateTweetJsonQueue(); //throw tweets into queue for processing } } catch(WebException e) { BackOffStrategy(e); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload