Classic ASP Requires Chilkat v11.0.0+
Classic ASP
Clickatell One API: Look up SMS delivery status
See more Clickatell Examples
Use the apiMessageId returned by the One API send example and the same integration key. The ID goes in the URL path. The SMS result contains sms.status and the timestamp of the last status change. For example, QUEUED means processing is pending and DEVICE_ACK indicates a device acknowledgment.
The response can also contain a WhatsApp result or have no identifiable channel for an unknown message. For ongoing delivery updates, configure delivery notifications in the integration. This example performs one lookup.
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
' Supply the key for this One API integration from application configuration.
http.SetRequestHeader "Authorization","ONE_API_KEY"
http.SetRequestHeader "Accept","application/json"
' Use the provider-generated ID from an accepted One API send.
success = http.SetUrlVar("id","ONE_API_MESSAGE_ID")
set resp = Server.CreateObject("Chilkat.HttpResponse")
success = http.HttpNoBody("GET","https://platform.clickatell.com/v1/message/{$id}",resp)
If (resp.StatusCode = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Check the connection and retry the lookup.") & "</pre>"
Response.End
End If
set reply = Server.CreateObject("Chilkat.JsonObject")
parsed = reply.Load(resp.BodyStr)
If ((success <> 1) Or ((resp.StatusCode <> 200))) Then
Response.Write "<pre>" & Server.HTMLEncode( "Clickatell returned HTTP " & resp.StatusCode) & "</pre>"
If (parsed = 1) Then
If (reply.HasMember("error.description") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( reply.StringOf("error.description")) & "</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 known SMS has a string status under the sms member.
If (reply.JsonTypeOf("sms.status") <> 1) Then
If (reply.JsonTypeOf("whatsapp.status") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "This message has WhatsApp status: " & reply.StringOf("whatsapp.status")) & "</pre>"
Else
Response.Write "<pre>" & Server.HTMLEncode( "No SMS status was returned. Check the message ID and integration.") & "</pre>"
If (reply.JsonTypeOf("status") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Reported status: " & reply.StringOf("status")) & "</pre>"
End If
End If
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "SMS status: " & reply.StringOf("sms.status")) & "</pre>"
If (reply.JsonTypeOf("sms.timestamp") = 2) Then
' Read the provider timestamp as text to preserve every digit.
Response.Write "<pre>" & Server.HTMLEncode( "Last status change (provider timestamp): " & reply.StringOf("sms.timestamp")) & "</pre>"
End If
%>
</body>
</html>