Geeks With Blogs

News



Add to Google

Tim Hibbard CEO for EnGraph software

In ParaPlan 4.0, we use twitter to maintain a change log.  I wanted to display this information to our users, so I wrote a little class that calls the RSS feed and uses LINQ to parse the data.  All I need is the message and the date, so that is all it pulls out.

Here is the class:

public class Twitter
{
    public string Message { get; set; }
    public DateTime PubDate { get; set; }
 
    public static List<Twitter> Parse(string User)
    {
        var rv = new List<Twitter>();
        var url = "http://twitter.com/statuses/user_timeline/" + User + ".rss";
 
        var element = XElement.Load(url);
        foreach (var node in element.Element("channel").Elements("item"))
        {
            var twit = new Twitter();
            var message = node.Element("description").Value;
            //remove username information
            twit.Message = message.Replace(User + ": ", string.Empty);
            twit.PubDate = DateTime.Parse(node.Element("pubDate").Value);
            rv.Add(twit);
        }
 
        return rv;
 
    }
}

Our calling code looks like this:

var changes = new List<string>();
 
var fromTwitter = Twitter.Parse("ParaPlan");
fromTwitter.ForEach(t =>
    changes.Add(t.PubDate.ToString("MM/dd/yy") + " - " + t.Message));
 
var list = new ListBox();
 
list.ItemsSource = changes;

 

Technorati Tags: ,,,,
Posted on Monday, January 5, 2009 2:53 PM .NET , Goldstar , WPF | Back to top


Comments on this post: Simple class to parse Twitter with LINQ

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Sweet dude! I really got to get to work on WMTwit.
Left by Robz on Jan 06, 2009 9:37 PM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Ah, yes. Parsing twitter! I concur. :)
Left by Chelsea on Feb 25, 2009 12:23 AM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Interesting - I've also seen a lot of posts about LinqToTwitter recently -http://www.codeplex.com/LinqToTwitter

If nothing else, I love the name!
Left by Stuart on Mar 20, 2009 3:16 AM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Thank you for sharing this valuable information. I hope everyone will also find it very helpful. Keep posting!
Left by internet marketing product revie on May 04, 2011 11:13 PM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
LINQ address the current database development model in the context of Object Oriented Programming Model. If some one wants to develop database application on .Net platform the very simple approach he uses ADO.Net. ADO.Net is serving as middle ware in application and provides complete object oriented wrapper around the database SQL.
Left by Fertility Jewelry on May 26, 2011 5:28 AM

# # re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
A friend often reminds me about this website but in fact this is the very first page I have checked out so far. I am highly pleased and right now an aficionado. Well I am adding this RSS to my e-mail and could look forward for much more of your respective intriguing content. Make sure you update this again soon.
Left by 4Hour Body on Jul 07, 2011 2:10 AM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Twitter is one of the best social networking site these days. Everyone is indulged in this. Twitter with Linq will work so nicely.
Left by Employment news on Nov 24, 2011 11:50 PM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Thank you for sharing this information. I was looking this type of post for a long time.
Left by Kitap on Apr 11, 2012 6:17 AM

# re: Simple class to parse Twitter with LINQ
Requesting Gravatar...
Thank you for your post. I think that, twitter is the best social network too.
Left by Oyuncak on Sep 21, 2012 12:31 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Hibbard | Powered by: GeeksWithBlogs.net