C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
 

Code Snippets

  

C# Source Code



Twitter API: Send Direct Message

This procedure will send a Twitter Direct Message to a specific user.

Submitted By: Core
Actions:
Rating:
Views: 1,371

Language: C#

Last Modified: July 14, 2009
Instructions: This namespace declaration should be included in the program:

using System.Net;

Snippet


  1. public static void sendDirectMessage(string username, string password, string sendTo, string message)
  2.         {
  3.             HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/direct_messages/new.xml?user=" + sendTo + "&text=" + message);
  4.             messageRequest.Method = "POST";
  5.             messageRequest.Credentials = new NetworkCredential(username, password);
  6.             messageRequest.ContentLength = 0;
  7.             messageRequest.ContentType = "application/x-www-form-urlencoded";
  8.             WebResponse response = messageRequest.GetResponse();
  9.         }

Copy & Paste


Comments

creativecoding 2010-01-20 01:53:49

Thanks!

Sumit Thakur 2010-02-07 21:51:38

great work


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.