Sending messages using the Esendex API and classic ASP

Help with the Esendex API

Sending messages using the Esendex API and classic ASP

Postby Jonathan » Tue Mar 16, 2010 4:02 am

The following example shows how you can use classic ASP to send SMS using the new Esendex API. You will need MSXML2 support on your ASP server, which should be included with Windows Server IIS installations.
The only additional step is the requirement to base64 encode your Esendex username and password. You should base64 encode the string username:password. So if your username is example@example.com and your password is letmein then you would encode 'example@example.com:letmein'.
The resulting string should replace 'BASE64_ENCODED_CREDENTIALS' in the following code.

The Esendex Account Reference that you want to send the messages through should be inserted into the code where EX00000 is currently. Change the <to></to> value and the <body></body> value to where and what you want to send the message to.

Here's the code:

<%
Dim oXMLHTTP
Dim xmlRequest
Dim xmlResponse

Set oXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
Set xmlRequest = Server.CreateObject("MSXML2.DOMDocument.3.0")
Set xmlResponse = Server.CreateObject("MSXML2.DOMDocument.3.0")


xmlRequest.loadXML("<messages><message><from>ORIGINATOR</from><to>123456789</to><type>SMS</type><body> This is a SMS message </body></message></messages>")

oXMLHTTP.Open "POST", "http://api.esendex.com/v0.8/Account/EX000000/messagedispatcher", False
oXMLHTTP.setRequestHeader "Authorization", "Basic BASE64_ENCODED_CREDENTIALS"
oXMLHTTP.Send(xmlRequest.xml)

xmlResponse.loadXML(oXMLHTTP.responseText)

Response.ContentType = "text/xml"
Response.Write xmlResponse.xml
Set oXMLHTTP = Nothing

%>
Jonathan
 
Posts: 7
Joined: Thu Mar 04, 2010 5:48 pm

Return to API



cron
© Esendex Ltd 2010
Company Registration Number: 04217280