Sample code for 30+ languages & platforms
VB.NET Requires Chilkat v11.0.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.

Clickatell API reference

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim http As New Chilkat.Http
http.RequireSslCertVerify = True

'  Use the key issued for this HTTP integration. Chilkat encodes each query value.
Dim query As New 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.")
Dim sender As String = ""
If (sender <> "") Then
    query.AddParam("from",sender)
End If

Dim resp As New Chilkat.HttpResponse
success = http.HttpReq("https://platform.clickatell.com/messages/http/send",query,resp)
If (resp.StatusCode = 0) Then
    Debug.WriteLine("The send outcome is unknown. Check the message report before resending.")
    Exit Sub
End If

Dim reply As New Chilkat.JsonObject
Dim parsed As Boolean = reply.Load(resp.BodyStr)
If ((success <> True) Or ((resp.StatusCode <> 202))) Then
    Debug.WriteLine("Clickatell returned HTTP " & resp.StatusCode)
    If (parsed = True) Then
        If (reply.HasMember("errorDescription") = True) Then
            Debug.WriteLine(reply.StringOf("errorDescription"))
        End If

    End If

    Exit Sub
End If

If (parsed <> True) Then
    Debug.WriteLine("Expected a JSON response.")
    Exit Sub
End If

'  A request-level error applies to the submission as a whole.
If (reply.HasMember("errorCode") = True) Then
    If (reply.IsNullOf("errorCode") <> True) Then
        Debug.WriteLine("Submission error " & reply.StringOf("errorCode") & "  " & reply.StringOf("errorDescription"))
        Exit Sub
    End If

End If

Dim count As Integer = reply.SizeOfArray("messages")
If (count <= 0) Then
    Debug.WriteLine("No recipient results returned. Check the message report before resending.")
    Exit Sub
End If

Dim i As Integer = 0
While (i < count)
    reply.I = i
    Dim resultNumber As Integer = i + 1
    '  JsonTypeOf returns 5 for a JSON boolean.
    If (reply.JsonTypeOf("messages[i].accepted") <> 5) Then
        Debug.WriteLine("Result " & resultNumber & " has no acceptance flag.")
    Else
        If (reply.BoolOf("messages[i].accepted") = True) Then
            Dim messageId As String = reply.StringOf("messages[i].apiMessageId")
            If ((reply.JsonTypeOf("messages[i].apiMessageId") <> 1) Or (messageId = "")) Then
                Debug.WriteLine("Result " & resultNumber & " was accepted without a tracking ID.")
            Else
                Debug.WriteLine("Result " & resultNumber & " accepted. Message ID: " & messageId)
            End If

        Else
            Debug.WriteLine("Result " & resultNumber & " rejected: " & reply.StringOf("messages[i].errorCode") & "  " & reply.StringOf("messages[i].errorDescription"))
        End If

    End If

    i = i + 1
End While