Hi Experts,
I am trying to post text message from my asp.net web sites.. to
twitter
I tried many sample codes but none of them worked
void SendDirectMessage(string username, string password, string
sendTo, string message)
{
HttpWebRequest messageRequest =
(HttpWebRequest)WebRequest.Create("http://twitter.com/direct_messages/
new.xml?user=" + sendTo + "&text=" + message);
messageRequest.Method = "POST";
messageRequest.Credentials = new NetworkCredential(username,
password);
messageRequest.ContentLength = 0;
messageRequest.ContentType = "application/x-www-form-
urlencoded";
WebResponse response = messageRequest.GetResponse();
}
void SendDirectMessage(String strMessage)
{
String strTweet = "status=" + Server.HtmlEncode(strMessage);
Byte[] bRequest =
System.Text.Encoding.ASCII.GetBytes(strTweet);
HttpWebRequest objRequest =
(HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/
update.xml");
objRequest.Credentials = new NetworkCredential("xxxxxx",
"xxxxxx");
objRequest.Method = "POST";
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.ServicePoint.Expect100Continue = false;
objRequest.ContentLength = bRequest.Length;
Stream objStream = objRequest.GetRequestStream();
objStream.Write(bRequest, 0, bRequest.Length);
objStream.Close();
WebResponse objResponse = objRequest.GetResponse();
StreamReader objReader = new
StreamReader(objResponse.GetResponseStream());
string data = objReader.ReadToEnd();
}
Getting an error message like below...
The remote server returned an error: (401) Unauthorized.
Any help would be appreciated
Thanks
Deepu
--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group:
http://groups.google.com/group/twitter-development-talk