There are quite a few examples on the web for sending Tweets to your own timeline using scripting and Curl, etc. However, I didn't find a lot of helpful examples on sending direct messages via Twitter using VBscript or KiXtart, so here's what I figured out and it seems to work. For more information on using the Direct_Messages.New API methods, refer to the Twitter API. Enjoy!
Const username = "MyTwitterUserName"
Const password = "MyTwitterPassword"
Const recipient = "skatterbrainz"
Function Twitter_Send_Direct(strMsg, recipient)
Dim oXml, strTwitterURL
strTwitterURL = "http://twitter.com/direct_messages/new.xml"
Set oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXml.Open "POST", strTwitterURL, False, username, password
oXml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXml.Send "text=" & strMsg & "&user=" & recipient
Twitter_Send_Direct = oXml.responseText
Set oXml = Nothing
msg = "Test Message (sent from vbscript)"
result = Twitter_Send_Direct(msg, recipient)
$username = "MyTwitterUserName"
$password = "MyTwitterPassword"
$recipient = "skatterbrainz"
Function Twitter_Send_Direct($strMsg, $recipient)
Dim $oXml, $strTwitterURL
$strTwitterURL = "http://twitter.com/direct_messages/new.xml"
$oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
$oXml.Open("POST", $strTwitterURL, 0, $username, $password)
$Twitter_Send_Direct = $oXml.responseText
$oXml = 0
$msg = "Test Update (sent from kixtart script)"
$result = Twitter_Send_Direct($msg, $recipient)
Note the wrapping of arguments with matching parenthesis (…) when using KiXtart. This is not required for VBScript. A small but important thing to keep in mind if you use both languages (as I do quite often). Another “feature” which I have mentioned in previous posts, is that KiXtart supports inline string/variable expansion, so you can bury variables within strings and they work fine, which is nice. PowerShell and some other languages can do that, but not VBScript.