Here is the improved code, now it won’t run in to the Twitter Request Per Day Limit.
static void Main(string[] args)
{
/*
* URL for Favoirtes: http://twitter.com/favorites/YourUserNameOnTwitter.xml?page=1
*/
WebRequest req;
req = WebRequest.Create( (string.Format(“http://twitter.com/favorites/YourUserNameOnTwitter.xml?page={0}”, 1)));
NetworkCredential creds = new NetworkCredential(“YourUserNameOnTwitter”, “YouUserNameTwitterPassword”);
req.Credentials = creds;
req.Method = “GET”;
string respString = “”;
for (int i = 101; i < 160; i++)
{
req = WebRequest.Create(string.Format(“http://twitter.com/favorites/YourUserNameOnTwitter.xml?page={0}”, i));
WebResponse resp = (WebResponse)req.GetResponse();
Stream respStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(respStream);
respString = respString + reader.ReadToEnd();
reader.Close();
respStream.Close();
resp.Close();
Console.Write(respString);
}
// create a writer and open the file
TextWriter tw = new StreamWriter(“C:\YourUserNameOnTwitterFavorite.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();
}
Grab it while it is hot!
Anyone out there who wanna work with me to improve it? Sky is the limit people!
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:
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();
}