Twitter API - Sending a Direct Message in C#
I tried writing some code to send a direct message using the
Twitter API. It was a FAIL. I did some searching in google,
and found this method below listed in a google group. I
didn't write it, but it works, so enjoy. I plugged the
method into my WCF Service and it just worked.
public void DMSend(string username, string recipient, string tweet)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://twitter.com/direct_messages/new.xml?user=" + recipient + "&text=" + tweet);
req.Method = "POST";
req.Credentials = new NetworkCredential(username, password);
req.ContentLength = 0;
req.ContentType = "application/x-www-form-urlencoded";
WebResponse response = req.GetResponse();
}
Original Url: http://morewally.com/cs/blogs/wallym/archive/2009/03/19/twitter-api-sending-a-direct-message-in-c.aspx