AutoIt Requires Chilkat v11.0.0+
AutoIt
Check message delivery status with Twilio
See more Twilio Examples
Fetch an outbound SMS or MMS using the Message SID returned by a live send. A queued message is waiting to be sent. A sent message has been accepted by the upstream carrier. Delivered means Twilio received delivery confirmation. Some routes provide no final delivery receipt.
Read the current status once per lookup. For failed or undelivered messages, display the available delivery error code and text for troubleshooting. A missing message or an HTTP authentication error is a separate result from a delivery failure.
Chilkat AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
; Load an API key for the Twilio account from private application configuration.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
$oHttp.BasicAuth = True
$oHttp.Login = "YOUR_API_KEY_SID"
$oHttp.Password = "YOUR_API_KEY_SECRET"
$oUrl = ObjCreate("Chilkat.StringBuilder")
$oUrl.Append("https://api.twilio.com/2010-04-01/Accounts/")
$oUrl.Append("YOUR_ACCOUNT_SID")
$oUrl.Append("/Messages")
$oUrl.Append("/")
$oUrl.Append("YOUR_MESSAGE_SID")
$oUrl.Append(".json")
$oResp = ObjCreate("Chilkat.HttpResponse")
$oReply = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oHttp.HttpNoBody("GET",$oUrl.GetAsString(),$oResp)
If ($oResp.StatusCode = 0) Then
ConsoleWrite("No HTTP response from Twilio." & @CRLF)
Exit
EndIf
Local $bParsed = $oReply.Load($oResp.BodyStr)
If (($bSuccess <> True) Or ($oResp.StatusCode <> 200)) Then
ConsoleWrite("Twilio returned HTTP " & $oResp.StatusCode & @CRLF)
If (($bParsed = True) And ($oReply.JsonTypeOf("code") = 2)) Then
ConsoleWrite("Twilio error: " & $oReply.IntOf("code") & " " & $oReply.StringOf("message") & @CRLF)
EndIf
Exit
EndIf
If ($bParsed <> True) Then
ConsoleWrite("Expected a JSON response from Twilio." & @CRLF)
Exit
EndIf
If ($oReply.JsonTypeOf("status") <> 1) Then
ConsoleWrite("Message status missing from response." & @CRLF)
Exit
EndIf
ConsoleWrite("Delivery status: " & $oReply.StringOf("status") & @CRLF)
If (($oReply.StringOfEquals("status","failed",True) = True) Or ($oReply.StringOfEquals("status","undelivered",True) = True)) Then
If ($oReply.JsonTypeOf("error_code") = 2) Then
ConsoleWrite("Delivery error code: " & $oReply.IntOf("error_code") & @CRLF)
EndIf
If ($oReply.JsonTypeOf("error_message") = 1) Then
ConsoleWrite($oReply.StringOf("error_message") & @CRLF)
EndIf
EndIf