Srikanth Technologies

Twitter.com Client In C#

It is possible to access your updates that you posted at twitter.com using C#.Net.

Though there are a couple of ways, the simplest is to use a library that provides methods to return your updates in different formats.

I found Yedda Twitter Library very simple to use.

Here are the steps to follow to download and use Yedda Twitter Library to get your own updates in the form of XML and then display time and text for each update.

  1. First go to http://devblog.yedda.com/index.php/twitter-c-library and download Yedda Twitter Library using the link at the bottom of the page.

    You get yeddatwitter-v01.zip. Unzip this file and you find Yedda.Twitter.dll library in bin/release folder.

  2. Create a new website called TwitterClient and select C# as the language.
  3. Add a webform called TwitterUpdates.aspx.
  4. Select website in Solution Explorer and click on right button to invoke popup menu.
  5. Select Add Reference option from popup menu and select Browse tab in Add Reference window. Select Yedda.Twitter.dll fromfrom the folder to which it was extracted.
  6. Write the following code in an .aspx page to display time at which update was posted along with text. class="code"> using System; using System.Xml; public partial class TwitterUpdates : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Yedda.Twitter twitter = new Yedda.Twitter(); // create object that provides required methods // connect to twitter with your username and password and get your updates in the form of XML XmlDocument updatesxml = twitter.GetUserTimelineAsXML("twitterusername", "twitterpassword"); XmlNodeList updates = updatesxml.SelectNodes("//status"); // use XPath and look for status elements foreach (XmlNode update in updates) // take one update at a time { string createdat = update["created_at"].InnerText ; // take time at which update was posted Response.Write( "<b>Posted At : </b> " + Server.HtmlEncode (createdat) + ""); string text = update["text"].InnerText ; // take text of the update Response.Write( "<b>Text : </b>" + Server.HtmlEncode (text) + "<hr/><p/>"); } } }
  7. Run the page while you are connected to Internet. You will see the list of updates that you most recently posted.
  8. YeddYedda library for Twitter contains a lot of other useful methods. Try other methods if you will.
  9. There are other libraries to access twitter from MS.Net. In fact you can access twitter from a lot of other languages like Java, PHP etc. To get the list of all available libraries, go to http://apiwiki.twitter.com/Libraries.

Keep going...

Post Your Comment

Image

Enter the code given in the above image :
Enter Your Name :
Enter Your Email Address :
Enter Your Comment :

Comments