|
Advanced Services - SMS Connectivity ASP JScript Sample application using HTTP to send an SMS text message |
![]() |
The following sample application written in ASP JScript sends an SMS text message to a single mobile telephone. The application uses HTTP to communicate with HSL's systems. To send to more than one mobile telephone at a time, separate each mobile number in the destaddr field by a comma (e.g. "447968000111,447720000111,3378100100").
<%@ Language = JScript%>
<html>
<head>
<title>Simple JScript (ASP) example for access to the HSL HTTP interface</title>
</head>
<body>
<%
// These variables fill out the various parts described in the
// interface specification
var host = "sms.haysystems.com";
var port = "80";
var action = "sendtxt";
var client_id = "<your client_id>";
var text = "this is a test message";
var destaddr = "<some fully-qualified MSISDN>";
var password = "<your secret>";
// Build and encode the URL.
// Note we are careful to URL-encode the message content as it is
// the only part of the URL likely to contain reserved characters.
var url = "http://" + host + ":" + port + "/" + action + "/";
var query = "client_id=" + client_id + "&text=" + Server.UrlEncode(text)
+ "&destaddr="+ destaddr + "&password=" + password;
// Create instance of the Inet control
var xml = Server.CreateObject("Microsoft.XMLHTTP");
xml.Open("POST", url, false);
xml.Send(query);
// Make the request and print the result
Response.Write("<p>Submission result: ");
Response.Write(xml.responseText);
Response.Write("</p>");
%>
</body>
</html>
super_simple_http_example_jscript.asp
Copyright © Hay Systems Ltd 2004
Owner: support@haysystems.com 20 September 2004