Classic ASP Requires Chilkat v11.0.0+
Classic ASP
Clickatell HTTP API: Send an SMS with query parameters
See more Clickatell Examples
Use an SMS integration configured for HTTP in the Clickatell Portal. The endpoint takes apiKey, to, and content as query parameters. Pass raw values to Chilkat so it can encode spaces, ampersands, and other reserved characters. Supply a country code and phone number as digits. Set from when your two-way integration requires a sender.
The URL contains the API key, recipient, and message text. Keep full request URLs out of logs and browser history. Check the per-message result after HTTP 202. If the connection is interrupted, check the Portal message report before resending. For the header-authenticated JSON workflow, see Send an SMS with One API.
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
' Use the key issued for this HTTP integration. Chilkat encodes each query value.
set query = Server.CreateObject("Chilkat.HttpRequest")
query.HttpVerb = "GET"
query.AddHeader "Accept","application/json"
query.AddParam "apiKey","HTTP_API_KEY"
query.AddParam "to","PHONE_NUMBER"
query.AddParam "content","Test message: pickup between 2 & 4."
sender = ""
If (sender <> "") Then
query.AddParam "from",sender
End If
set resp = Server.CreateObject("Chilkat.HttpResponse")
success = http.HttpReq("https://platform.clickatell.com/messages/http/send",query,resp)
If (resp.StatusCode = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "The send outcome is unknown. Check the message report before resending.") & "</pre>"
Response.End
End If
set reply = Server.CreateObject("Chilkat.JsonObject")
parsed = reply.Load(resp.BodyStr)
If ((success <> 1) Or ((resp.StatusCode <> 202))) Then
Response.Write "<pre>" & Server.HTMLEncode( "Clickatell returned HTTP " & resp.StatusCode) & "</pre>"
If (parsed = 1) Then
If (reply.HasMember("errorDescription") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( reply.StringOf("errorDescription")) & "</pre>"
End If
End If
Response.End
End If
If (parsed <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON response.") & "</pre>"
Response.End
End If
' A request-level error applies to the submission as a whole.
If (reply.HasMember("errorCode") = 1) Then
If (reply.IsNullOf("errorCode") <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Submission error " & reply.StringOf("errorCode") & " " & reply.StringOf("errorDescription")) & "</pre>"
Response.End
End If
End If
count = reply.SizeOfArray("messages")
If (count <= 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "No recipient results returned. Check the message report before resending.") & "</pre>"
Response.End
End If
i = 0
Do While (i < count)
reply.I = i
resultNumber = i + 1
' JsonTypeOf returns 5 for a JSON boolean.
If (reply.JsonTypeOf("messages[i].accepted") <> 5) Then
Response.Write "<pre>" & Server.HTMLEncode( "Result " & resultNumber & " has no acceptance flag.") & "</pre>"
Else
If (reply.BoolOf("messages[i].accepted") = 1) Then
messageId = reply.StringOf("messages[i].apiMessageId")
If ((reply.JsonTypeOf("messages[i].apiMessageId") <> 1) Or (messageId = "")) Then
Response.Write "<pre>" & Server.HTMLEncode( "Result " & resultNumber & " was accepted without a tracking ID.") & "</pre>"
Else
Response.Write "<pre>" & Server.HTMLEncode( "Result " & resultNumber & " accepted. Message ID: " & messageId) & "</pre>"
End If
Else
Response.Write "<pre>" & Server.HTMLEncode( "Result " & resultNumber & " rejected: " & reply.StringOf("messages[i].errorCode") & " " & reply.StringOf("messages[i].errorDescription")) & "</pre>"
End If
End If
i = i + 1
Loop
%>
</body>
</html>