by aherrick
29. September 2008 15:06
I was looking for an easy solution to add Twitter to my blog, and decide to write a class extension to fit my needs. With input from Fence Row Productions I came up with a class to easily grab your most recent tweet and display it on your blog. The code will parse Twitter API to display your most recent Tweet.
Check out how I am currently using it.
Added two ASP.NET label controls "lblTweet" and "lblTweetInfo." Also added an image control "imgTweet."
Here is my current code behind file for my MasterPage. The class constructor is your Twitter login name (twitter.com/you)
imgTweet.ImageUrl = "~/pics/twitter_bird_32.png";
Twitter t = new Twitter("andrew_herrick");
this.lblTweet.Text = t.TweetStatus;
this.lblTweetInfo.Text =
string.Format("<a href='{0}' target='NEW'>{1}</a> from {2}.",
t.TweetURL, t.TweetDateDiff, t.TweetSource);
Attached is the complete class. Let me know how it goes and enjoy!
Twitter.cs (4.65 kb)
1035ce83-c466-4359-889d-f7db1278f146|3|4.3
Tags: c#