Thanks to the Twitter API documentation (which is lacking examples) and the MSDN reference library on using MSXML/XMLHTTP methods, I’ve put together a simple script to query your Twitter DM inbox and fetch the 20 most recent items (that’s the built-in default of the Twitter API, by the way). Enjoy!VBscript Example:
Const username = "MyTwitterUserName"
Const password = "MyTwitterPassword"
Dim oXml, strTwitterURL : strTwitterURL = "http://twitter.com/direct_messages.xml"
Set oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXml.Open "GET", strTwitterURL, False, strUser, strPass
oXml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
Twitter_Get_Direct = oXml.responseText
Set oXml = Nothing
result = Twitter_Get_Direct(username, password)
$username = "MyTwitterUserName"
$password = "MyTwitterPassword"
Dim $oXml, $strTwitterURL
$strTwitterURL = "http://twitter.com/direct_messages.xml"
$oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
$oXml.Open("GET", $strTwitterURL, 0, $strUser, $strPass)
$Twitter_Get_Direct = $oXml.responseText
$oXml = 0
$result = Twitter_Get_Direct($username, $password)
I could probably post this in PowerShell also, but nobody seems to care, so unless someone asks I won’t bother. Anyhow: putting this together with the previous examples and blog rants, using a little duct tape and glue, you can assemble a nifty little system for monitoring remote servers using Twitter, as well as sending control commands to the remote server to execute. That’s right. You can use the above script on a server to fetch DM messages and process them. I’ll leave that to your imagination, but it does work and is pretty simple to do. The only caveate is Twitter availability (not very good) and how robust you want to make the contraption. Cheers!