Sending a fairly simple POST request to the Twilio SMS API:
cfhttp(
method = "POST",
charset = "utf-8",
url = Twilio_API,
username = Account_SID,
password = Auth_Token,
result = "myResult"){
//
cfhttpparam(
type = "formField",
name = "To",
value = '+1615*******');
//
cfhttpparam(
type = "formField",
name = "From",
value = '+1714*******');
//
cfhttpparam(
type = "formField",
name = "Body",
value = 'This is a test message!');
//
cfhttpparam(
type = "formField",
name = "StatusCallback",
value = URLEncode(StatusCallback));
//
}
The last parameter is the problem:
cfhttpparam(
type = "formField",
name = "StatusCallback",
value = URLEncode(StatusCallback));
//
If I URLEncode the StatusCallback URL (in the 'StatusCallback' variable), Twilio replies with an 'Error - 21609 Invalid StatusCallback URL' - however, the encoding is correct according to RFC 3986, and confirmed at https://www.urlencoder.org/ (UTF-8 conversion). It's a pretty simple process. The issue we're having is that if we properly URLEncode the StatusCallback URL, we get the error, and if we don't encode the URL, we don't get anything - no error, and no StatusCallback to our servers, but the actual SMS still goes through with no problems. Nothing shows up in our logs either way - Twilio never reaches out to our server.
Is there some sort of special URLEncoding format that we need to adopt to get Twilio to recognize our StausCallback handler URL? There's nothing special about the URL, either:
http://xxxxxxxxxxxx.yyy/Twilio_CBS/hTwilioCallBack.cfm
I did note that Twilio is picky about the case of their parameters ('statusCallback' as a FORM field fails, whereas 'StatusCallback' works fine).
Any ideas? We're primarily interested in figuring out how to get the callback URL encoded so Twilio likes it, as opposed to retooling the entire approach.