Here's my simple code for connecting to Twitter with supplied
credentials:
void dologin(string username, string password){
try{
string myURL = "http://"+username+":"+password+"@
twitter.com/
statuses/user_timeline.xml";
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(myURL);
HttpWebResponse hwrsp = (HttpWebResponse)hwr.GetResponse();
StreamReader sr = new StreamReader(hwrsp.GetResponseStream());
Console.WriteLine(sr.ReadToEnd());
sr.Close();
}
catch(Exception e){
Console.WriteLine(e.ToString());
}
}
When the connection is tried, the following error is returned:
System.Net.WebException: The remote server returned an error: (401)
Unauthorized.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at UserUi.dologin(String username, String password)
When I request
http://twitter.com/statuses/user_timeline/user.xml, the
proper output is given, even though no authentication has occurred.
What's going on?
Mod