Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.0
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 Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim http As New ChilkatHttp
http.RequireSslCertVerify = 1
' Use the key issued for this HTTP integration. Chilkat encodes each query value.
Dim query As New ChilkatHttpRequest
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."
Dim sender As String
sender = ""
If (sender <> "") Then
query.AddParam "from",sender
End If
Dim resp As New ChilkatHttpResponse
success = http.HttpReq("https://platform.clickatell.com/messages/http/send",query,resp)
If (resp.StatusCode = 0) Then
Debug.Print "The send outcome is unknown. Check the message report before resending."
Exit Sub
End If
Dim reply As New ChilkatJsonObject
Dim parsed As Long
parsed = reply.Load(resp.BodyStr)
If ((success <> 1) Or ((resp.StatusCode <> 202))) Then
Debug.Print "Clickatell returned HTTP " & resp.StatusCode
If (parsed = 1) Then
If (reply.HasMember("errorDescription") = 1) Then
Debug.Print reply.StringOf("errorDescription")
End If
End If
Exit Sub
End If
If (parsed <> 1) Then
Debug.Print "Expected a JSON response."
Exit Sub
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
Debug.Print "Submission error " & reply.StringOf("errorCode") & " " & reply.StringOf("errorDescription")
Exit Sub
End If
End If
Dim count As Long
count = reply.SizeOfArray("messages")
If (count <= 0) Then
Debug.Print "No recipient results returned. Check the message report before resending."
Exit Sub
End If
Dim i As Long
i = 0
Do While (i < count)
reply.I = i
Dim resultNumber As Long
resultNumber = i + 1
' JsonTypeOf returns 5 for a JSON boolean.
If (reply.JsonTypeOf("messages[i].accepted") <> 5) Then
Debug.Print "Result " & resultNumber & " has no acceptance flag."
Else
If (reply.BoolOf("messages[i].accepted") = 1) Then
Dim messageId As String
messageId = reply.StringOf("messages[i].apiMessageId")
If ((reply.JsonTypeOf("messages[i].apiMessageId") <> 1) Or (messageId = "")) Then
Debug.Print "Result " & resultNumber & " was accepted without a tracking ID."
Else
Debug.Print "Result " & resultNumber & " accepted. Message ID: " & messageId
End If
Else
Debug.Print "Result " & resultNumber & " rejected: " & reply.StringOf("messages[i].errorCode") & " " & reply.StringOf("messages[i].errorDescription")
End If
End If
i = i + 1
Loop