For information on how to use a proxy server with the ServerXMLHttp object please see the setProxy and setProxyCredentials methods in the MSXML documentation http://msdn.microsoft.com/en-us/library/ms757828(v=VS.85).aspx
The script is a Windows Script Host file so simply paste it into a file ending with .wsf, edit the credentials and double click it to run. The code is only illustrative and should be easy to copy to VBScript or VB6.
- Code: Select all
<job id="main">
<script language="VBScript">
Option Explicit
Dim mUsername
Dim mPassword
Dim mAccountReference
mUsername = "myusername"
mPassword = "mypassword"
mAccountReference = "myaccount"
Const ServiceURL = "http://api.esendex.com/v1.0/messagedispatcher"
Function SubmitCommand(RESTRequest)
Dim Server
Set Server = CreateObject("MSXML2.ServerXMLHttp")
Server.Open "POST", ServiceURL, False, mUsername, mPassword
Server.setRequestHeader "Content-Type", "text/xml"
Server.setRequestHeader "Content-Length", Len(RESTRequest)
'ERROR HERE
'On Error GoTo ErrHandle
Server.send RESTRequest
WScript.Echo "Response HTTP status: " & Server.Status & " " & Server.StatusText
SubmitCommand = Server.responseText
Exit Function
ErrHandle:
End Function
Function SendTextMessage(strTo, strBody)
Dim strCommand
Dim responseText
strCommand ="<?xml version=""1.0"" encoding=""utf-8"" ?>" & vbCrLf & _
"<messages>" &_
" <accountreference>" & mAccountReference & "</accountreference>" &_
" <message>" & _
" <to>" & strTo & "</to>" & _
" <body>" & strBody & "</body>" & _
" </message>" &_
"</messages>"
responseText = SubmitCommand(strCommand)
SendTextMessage = responseText
End Function
Dim response
WScript.Echo "Sending message"
response = SendTextMessage ("07875488241", "This is a where your text message content should go!")
WScript.Echo "Response: " & response
</script>
