So you want to know what is happening right now. Twitter Search is the way. Constructing a query and parsing the ATOM is pretty easy.
Recently hit a gotcha where the network my app was running was caching the results. The way to override was to create a WebClient and set the cache policy explicitly. You can see how that works by setting the RequestCacheLevel to NoCacheNoStore. Then, call OpenRead() on the WebClient.
After that, I use Linq to parse the results. One gotcha is the need to explicitly add the namespace when querying the results. (If there is a better way, let me know!)
Here's the code.
string xml;
string term = "mix09";
using (WebClient webclient = new WebClient())
{
RequestCachePolicy policy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
webclient.CachePolicy = policy;
Stream stream = webclient.OpenRead
(string.Format("http://search.twitter.com/search.atom?q={0}", term));
StreamReader sr = new StreamReader(stream);
xml = sr.ReadToEnd();
sr.Close();
}
XDocument doc = XDocument.Parse(xml);
XNamespace xmlns = "http://www.w3.org/2005/Atom";
var tweet = from entry in doc.Descendants(xmlns + "entry")
select new
{
Content = entry.Element(xmlns + "title").Value,
Date = entry.Element(xmlns + "published").Value,
Author = entry.Element(xmlns + "author").Element(xmlns + "uri").Value.Replace("http://twitter.com/", ""),
Image = entry.Elements(xmlns + "link").ElementAt(1).Attribute("href").Value
};
foreach (var c in tweet)
{
//do something here...
}
Note this code is used in Flotzam!