Twitter Favorite Harvester in C#.

Finally able to get the Favoirte (in a XML format) from Twitter with that nifty script, I encouraged anyone out there to improve it and share it here, and we can build a nifty tool that will feature as follow:

  1. Export the cool links from your Twitter Favoirtes to Digg or Delicious Account or Bookmarks2.com
  2. Export the harvested Links to Firefox or any browser
  3. Export the Fav. Tweets in a nice “Reousrce” file or whatever the storage you are using.
  4. Share among friends.

Sample Code is here, please provide your feedback, I encountered the Request Limt from Twitter, but if you know the better way and to beat the limit, it would be awesome:

static void Main(string[] args)
{
/*
* URL for Favoirtes: http://twitter.com/favorites/YourUserNameOnTwitter.xml?page=1
*/


string respString = “”;
for (int i = 95; i < 96; i++)
{
WebRequest req = WebRequest.Create(string.Format(“http://twitter.com/favorites/YourUserNameOnTwitter.xml?page={0}”, i));

NetworkCredential creds = new NetworkCredential(“YourUser”, “YourPassword”);

req.Credentials = creds;
req.Method = “GET”;
WebResponse resp = (WebResponse)req.GetResponse();

Stream respStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(respStream);

respString = reader.ReadToEnd();

reader.Close();
respStream.Close();
resp.Close();

Console.Write(respString);
}
// create a writer and open the file
TextWriter tw = new StreamWriter(“C:\FavoriteFile.txt”);

// write a harvested favorite tweets to the file
tw.WriteLine(respString);

//TODO: Parse the XML, and then make it available to be searched by Twitter UserID, Keyword, and harvest the URL out of it!
Console.ReadLine();



}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>