Page 2 of 2

Problems using Twilio in Server Code

Posted: Thu May 29, 2014 3:43 am
by Kal

Ahh! Makes a lot of sense. Thanks so much, Yurii!


Problems using Twilio in Server Code

Posted: Thu Oct 29, 2015 10:45 pm
by Jon Haider

Yurii,
The code that you provided works great, but I've been unable to figure out how to add a mediaURL to this method.

I've tried appending your coderequestBody/code, to where it looks like:
pre
var mediaURL = "https://www.google.com/images/nav_logo242.png";
var requestBody = "From=" + encodeURIComponent(myPhoneNumber) + "&To=" + encodeURIComponent(toPhone) + "&Body=" + encodeURIComponent(body) + "&MediaUrl=" + encodeURIComponent(mediaURL);
/pre

This media url works fine when using the Twilio tester interface.

Any advice?

UPDATE: As always, as soon as I post the question and continue to mess around with things, I got it to work...

The mistake I had was using the sendURL:
pre
var sendURL = "https://api.twilio.com/2010-04-01/Accounts/" + accountSid + "/SMS/Messages.json";
/pre

but you have to remove codeSMS//code from the url to become:
pre
var sendURL = "https://api.twilio.com/2010-04-01/Accounts/" + accountSid + "/Messages.json";
/pre
and it works fine.

Hope this helps the next lad...

Thanks!


Problems using Twilio in Server Code

Posted: Fri Oct 30, 2015 5:48 am
by Evgene Karachevtsev

Hello Jon,

Thank you for the post and for the update.