Hello everyone.
I using the following code to find people on twitter. but it gives me authentication problem (i-e) System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse();
my code goes here:
HttpWebRequest client = (HttpWebRequest)WebRequest.Create(“http://api.twitter.com/1/users/search.xml?q=testname”);
var ccache = new CredentialCache();
Uri uri = new Uri(“http://api.twitter.com/1/users/search.xml?q=testname”);
ccache.Add(uri, “Basic”, new NetworkCredential(username, password);
client.Credentials = ccache;
client.Timeout = 20000;
client.PreAuthenticate = true;
try
{
using (HttpWebResponse httpResponse = (HttpWebResponse)client.GetResponse())
{
using (Stream stream = httpResponse.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
}
}
Can anybody tell me how to handle this problem. or any other way to get peoples profiles form the twitter.
Thanks