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

Send an MMS with Twilio using a media URL

See more Twilio Examples

Send an image and an optional caption from an MMS-capable Twilio number. Supply an MMS-supported destination in E.164 format and replace the example media URL with an HTTPS URL Twilio can fetch. The host must handle HEAD and GET and return the correct Content-Type for the file.

Live send. With live credentials and valid inputs, this request submits a billable message. Save the Message SID to check delivery later. Supported media types and size limits.

Twilio Messages API reference

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Assumes Chilkat is unlocked. See Global Unlock Sample.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
$oHttp.BasicAuth = True
;  Load the owning Account SID and an API key from application configuration.
Local $sAccountSid = "YOUR_ACCOUNT_SID"
$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($sAccountSid)
$oUrl.Append("/Messages.json")

;  Add raw field values. Chilkat form-encodes them, including the + in a phone number.
$oReq = ObjCreate("Chilkat.HttpRequest")
$oReq.HttpVerb = "POST"
$oReq.ContentType = "application/x-www-form-urlencoded"
$oReq.AddParam "From","YOUR_MMS_ENABLED_NUMBER"
$oReq.AddParam "To","RECIPIENT_E164_NUMBER"
;  Supply a URL for the file itself so Twilio can retrieve the media.
$oReq.AddParam "MediaUrl","https://media.example.com/photo.jpg"
$oReq.AddParam "Body","Photo attached."

$oResp = ObjCreate("Chilkat.HttpResponse")
$oReply = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oHttp.HttpReq($oUrl.GetAsString(),$oReq,$oResp)
If ($oResp.StatusCode = 0) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

Local $bParsed = $oReply.Load($oResp.BodyStr)
If (($bSuccess <> True) Or ($oResp.StatusCode <> 201)) Then
    ConsoleWrite("HTTP " & $oResp.StatusCode & @CRLF)
    If (($bParsed = True) And ($oReply.HasMember("code") = True)) Then
        ConsoleWrite("Twilio error " & $oReply.IntOf("code") & ": " & $oReply.StringOf("message") & @CRLF)
    EndIf

    Exit
EndIf

If ($bParsed <> True) Then
    ConsoleWrite("Expected a JSON response." & @CRLF)
    Exit
EndIf

If (($oReply.JsonTypeOf("sid") <> 1) Or ($oReply.JsonTypeOf("status") <> 1)) Then
    ConsoleWrite("The create response is missing the message SID or status." & @CRLF)
    Exit
EndIf

ConsoleWrite("Message SID: " & $oReply.StringOf("sid") & @CRLF)
ConsoleWrite("Initial status: " & $oReply.StringOf("status") & @CRLF)