' The script can be called via
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% call sendsms("447740123456",1,"123 ABC TEST test","","")
if AQresponse <> "" then
response.write(AQresponse)
else
response.write("ERROR")
end if
%>
' Actual script follows. This could be placed in a separate file,
' such as the smslib.asp file described above
<%
response.buffer = true
' Copyright 2002 (aq) ltd.
' Script requires Microsoft XMLHTTP component
Dim method, secured, error_on_length, username, password, AQresponse
' User Editable Variables
secured = 0 ' Set to either 1 for SSL connection
' or 0 for normal connection.
error_on_length = 1 ' Whether to give and error on messages over 160 chracters.
' 1 for true, 0 for false.
username = "testusername" ' Your aql username, can either be set here
' or done on a per call basis from the function.
password = "testpassword" ' Your aql password, can either be set here
' or done on a per call basis from the function.
' Do not edit below here unless you know what you are doing!
Function sendsms(destination, flash, message, f_username, f_password, originator)
if f_username <> null or f_username <> "" then
username = f_username
end if
if f_password <> null or f_password <> "" then
password = f_password
end if
if username = "" then
call senderror(1)
else if password = "" then
call senderror(2)
else if destination = "" then
call senderror(3)
else if len(message) > 160 and error_on_length = 1 then
call senderror(6)
else if flash > 1 or flash < 0 then
call senderror(5)
end if
end if
end if
end if
end if
Dim objXMLHTTP, xml
message = replace(message," ","+")
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
if secured = null or secured = 0 then
xml.Open "POST", "http://gw1.aql.com/sms/sms_gw.php", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send "username=" & username & "&password=" & password & "&destination=" & destination &
"&message=" & message & "&originator=" & originator & "&flash=" & flash
else if secured = 1 then
xml.Open "POST", "https://gw1.aql.com/sms/sms_gw.php", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send "username=" & username & "&password=" & password & "&destination=" & destination &
"&message=" & message & "&originator=" & originator & "&flash=" & flash
else
call senderror(7)
end if
end if
AQresponse = xml.responseText
Set xml = nothing
End Function
Function senderror(id)
set xml = nothing
Select case(id)
case (1)
response.write
("No username was specified in either the function call or the config section")
response.end
case (2)
response.write
("No password was specified in either the function call or the config section")
response.end
case (3)
response.write ("No to number was set in the function call")
response.end
case (4)
response.write("No, or incorrect method specified")
response.end
case (5)
response.write("Invalid setting for Flash message flag, must be 1 or 0")
response.End
case (6)
response.write("Message was over 160 chars and was not sent.")
response.write("To disable this warning edit the flag in ""smslib.asp""")
response.end
case (7)
response.write("Invalied setting for Secure flag, must be 1 or 0")
response.end
end select
end function
%>
|