Twitter API and LinQ to XmL
Here is a simple C# exampel of how to retrive information from the Twitter API search in atom format.
Create a class to host the properties in a tweet.
class Tweet{
public string Id { get; set; }
public DateTime Published { get; set; }
public string Link { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public string Uri { get; set; }
}
To load the twitter search in atom format use the folling code:
XDocument feed = XDocument.Load(http://search.twitter.com/search.atom?q=sharepoint);
A method to parse the xml data using LinQ to XmL, and return it as a List<Tweet>.
XNamespace atomNS = "http://www.w3.org/2005/Atom";m_tweets = (from tweet in feed.Descendants(atomNS + "entry")
select new Tweet
{
Title = (string)tweet.Element(atomNS + "title"),
Published = DateTime.Parse((string)tweet.Element(atomNS + "published")),
Id = (string)tweet.Element(atomNS + "id"),
Link = tweet.Elements(atomNS + "link")
.Where(link => (string)link.Attribute("rel") == "alternate")
.Select(link => (string)link.Attribute("href"))
.First(),
Author = (string)tweet.Element(atomNS + "author").Element(atomNS + "name"),
Uri = (string)tweet.Element(atomNS + "author").Element(atomNS + "uri"),
}).ToList<Tweet>();
then its just to bind the List<Tweet> as a datasource to eg. a DataGridView or what ever suits your need.