Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.0.0+

Clickatell One API: Schedule a time-limited SMS reminder

See more Clickatell Examples

Schedule a reminder 15 minutes from now in UTC. The scheduledDeliveryTime includes its time zone and validityPeriod is expressed in minutes. Set both from the appointment and the period for which the reminder will still be useful. Use the returned message ID for a later status lookup.

Supply an international number as digits. Set the sender to the provisioned number when the integration requires it.

Clickatell API reference

Chilkat AutoIt Downloads

AutoIt
;  Assumes Chilkat is unlocked. See Global Unlock Sample.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
;  Load the key for this One API integration from your application configuration.
$oHttp.SetRequestHeader "Authorization","ONE_API_KEY"
$oHttp.SetRequestHeader "Accept","application/json"

$oSchedule = ObjCreate("Chilkat.CkDateTime")
$oSchedule.SetFromCurrentSystemTime()
$oSchedule.AddSeconds(900)
Local $sendAt = $oSchedule.GetAsTimestamp(False)
$oBody = ObjCreate("Chilkat.JsonObject")
$oBody.UpdateString("messages[0].channel","sms")
$oBody.UpdateString("messages[0].to","PHONE_NUMBER")
$oBody.UpdateString("messages[0].content","Appointment reminder: please check in at reception.")
$oBody.UpdateString("messages[0].scheduledDeliveryTime",$sendAt)
$oBody.UpdateInt("messages[0].validityPeriod",60)
Local $sender = ""
If ($sender <> "") Then
    $oBody.UpdateString("messages[0].from",$sender)
EndIf

ConsoleWrite("Requested send time (UTC): " & $sendAt & @CRLF)

$oResp = ObjCreate("Chilkat.HttpResponse")
Local $bSent = $oHttp.HttpJson("POST","https://platform.clickatell.com/v1/message",$oBody,"application/json",$oResp)
If ($oResp.StatusCode = 0) Then
    ConsoleWrite("No HTTP response. Check the message report before resending." & @CRLF)
    Exit
EndIf

$oReply = ObjCreate("Chilkat.JsonObject")
Local $bParsed = $oReply.Load($oResp.BodyStr)
If (($bSent <> True) Or ($oResp.StatusCode <> 202)) Then
    ConsoleWrite("Send returned HTTP " & $oResp.StatusCode & @CRLF)
    If ($oReply.HasMember("error.description") = True) Then
        ConsoleWrite($oReply.StringOf("error.description") & @CRLF)
    EndIf

    Exit
EndIf

If ($oReply.HasMember("error.code") = True) Then
    If ($oReply.IsNullOf("error.code") <> True) Then
        ConsoleWrite("Submission error " & $oReply.StringOf("error.code") & "  " & $oReply.StringOf("error.description") & @CRLF)
        Exit
    EndIf

EndIf

;  HTTP acceptance and the recipient result are separate checks.
If (($bParsed <> True) Or ($oReply.JsonTypeOf("messages[0].accepted") <> 5)) Then
    ConsoleWrite("Missing recipient result. Check the message report." & @CRLF)
    Exit
EndIf

If ($oReply.BoolOf("messages[0].accepted") <> True) Then
    ConsoleWrite("Message rejected: " & $oReply.StringOf("messages[0].error.code") & "  " & $oReply.StringOf("messages[0].error.description") & @CRLF)
    Exit
EndIf

If ($oReply.JsonTypeOf("messages[0].apiMessageId") <> 1) Then
    ConsoleWrite("Accepted without a message ID. Check the message report." & @CRLF)
    Exit
EndIf

ConsoleWrite("Accepted. Message ID: " & $oReply.StringOf("messages[0].apiMessageId") & @CRLF)