I'm trying to send an SMS using Twilio. I found an article (https://www.twilio.com/blog/2010/04/using-twilio-with-classic-asp-and-vbscript.html) that shows how to do this by VBScript, but I was wondering how to amend the script when sending a POST request from a client computer and not a server.
I tried to give this a first pass, but I'm not too familiar with VBScript. I found some articles saying to use the System.Web.HttpUtility to run URLEncode()
Any help would be much appreciated.
accountSid = "XXXX"
authToken = "XXXX"
baseUrl = "https://api.twilio.com"
smsUrl = baseUrl & "/2010-04-01/Accounts/" & accountSid & "/SMS/Messages"
' setup the request and authorization
Set http = CreateObject("MSXML2.XMLHTTP.6.0")
http.open "POST", smsUrl, False, accountSid, authToken
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
' message parameters
from = "XXX" ' the number to send the message from
recipient = "XXX" ' the number to send the message to
body = "Sending SMS is easy with Twilio!" ' message contents
Set sendbot=CreateObject(System.Web.HttpUtility)
postData = "From=" & sendbot.URLEncode(from)
postData = postData & "&To=" & sendbot.URLEncode(recipient)
postData = postData & "&Body=" & sendbot.URLEncode(body)
' send the POST data
http.send postData
' optionally write out the response if you need to check if it worked
' Response.Write http.responseText
' clean up
Set http = Nothing