[twitter-dev] Need Help on posting Message

2010-01-20 Thread Atul
Hello Frenz,

I'm building an application in C#.Net 3.5. My Requirement is to post
message to twitter user, defined by me in text box, on button click
i'm passing my credentials and user name with message but i' m getting
following error:-

the remote server returned an error 403 forbidden

My Code is Below:-

 try
   {
   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();
   }
   catch(Exception ex)
   {
   MessageBox.Show(ex.Message);
   }

any Help is Appreciated,


Re: [twitter-dev] Need Help on posting Message

2010-01-20 Thread ryan alford
You need to add this

messageRequest.ServicePoint.Expect100Continue = false;

so your code should look like this...

http://codepaste.net/ababkc

Ryan

On Wed, Jan 20, 2010 at 10:22 AM, Atul atul101...@gmail.com wrote:

 Hello Frenz,

 I'm building an application in C#.Net 3.5. My Requirement is to post
 message to twitter user, defined by me in text box, on button click
 i'm passing my credentials and user name with message but i' m getting
 following error:-

 the remote server returned an error 403 forbidden

 My Code is Below:-

  try
   {
   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();
   }
   catch(Exception ex)
   {
   MessageBox.Show(ex.Message);
   }

 any Help is Appreciated,