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

Schedule or cancel an SMS with Twilio

See more Twilio Examples

Live messaging operation. Choose one action per run. Scheduling requires an SMS-capable sender in a Twilio Messaging Service. Supply its MG SID, a recipient in E.164 format, and a send time from 15 minutes to 35 days in the future. The example uses UTC one hour from now. Twilio will send the scheduled message unless it is canceled in time.

Save the returned Message SID. To cancel later, select the cancel action and supply that SID under the same account. Check the returned status. If the message has already left the scheduled state, fetch its current status.

Twilio documentation

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
'  Load an API key for the Twilio account from private application configuration.
set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
http.BasicAuth = 1
http.Login = "YOUR_API_KEY_SID"
http.Password = "YOUR_API_KEY_SECRET"

set url = Server.CreateObject("Chilkat.StringBuilder")
success = url.Append("https://api.twilio.com/2010-04-01/Accounts/")
success = url.Append("YOUR_ACCOUNT_SID")
success = url.Append("/Messages")
'  Set this to true on a later run to cancel the saved message.
cancelMessage = 0
set req = Server.CreateObject("Chilkat.HttpRequest")
set sendTime = Server.CreateObject("Chilkat.CkDateTime")
req.HttpVerb = "POST"
req.ContentType = "application/x-www-form-urlencoded"
expectedHttp = 201
expectedStatus = "scheduled"
If (cancelMessage <> 1) Then
    timeOk = sendTime.SetFromCurrentSystemTime()
    If (timeOk <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( sendTime.LastErrorText) & "</pre>"
        Response.End
    End If

    timeOk = sendTime.AddSeconds(3600)
    If (timeOk <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( sendTime.LastErrorText) & "</pre>"
        Response.End
    End If

    req.AddParam "MessagingServiceSid","YOUR_MESSAGING_SERVICE_SID"
    req.AddParam "To","RECIPIENT_E164_NUMBER"
    req.AddParam "Body","Scheduled message."
    req.AddParam "ScheduleType","fixed"
    req.AddParam "SendAt",sendTime.GetAsTimestamp(0)
Else
    '  Update the individual message. This branch never creates another message.
    success = url.Append("/")
    success = url.Append("SAVED_SCHEDULED_MESSAGE_SID")
    req.AddParam "Status","canceled"
    expectedHttp = 200
    expectedStatus = "canceled"
End If

success = url.Append(".json")
set resp = Server.CreateObject("Chilkat.HttpResponse")
set reply = Server.CreateObject("Chilkat.JsonObject")

success = http.HttpReq(url.GetAsString(),req,resp)
If (resp.StatusCode = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response from Twilio.") & "</pre>"
    Response.End
End If

parsed = reply.Load(resp.BodyStr)
If ((success <> 1) Or (resp.StatusCode <> expectedHttp)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Twilio returned HTTP " & resp.StatusCode) & "</pre>"
    If ((parsed = 1) And (reply.JsonTypeOf("code") = 2)) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Twilio error: " & reply.IntOf("code") & "  " & reply.StringOf("message")) & "</pre>"
    End If

    Response.End
End If

If (parsed <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON response from Twilio.") & "</pre>"
    Response.End
End If

If ((reply.JsonTypeOf("sid") <> 1) Or (reply.JsonTypeOf("status") <> 1)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "The response is missing the message SID or status.") & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Message SID: " & reply.StringOf("sid")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Current status: " & reply.StringOf("status")) & "</pre>"
If (reply.StringOfEquals("status",expectedStatus,1) <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "The requested state was not confirmed. Check this SID before trying again.") & "</pre>"
    Response.End
End If

If (cancelMessage <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Save the Message SID to check or cancel the scheduled message.") & "</pre>"
End If


%>
</body>
</html>