Twilio Remote Web Service: passing --data-urlencode fields

Hello Everyone-

I am working on configuring Twilio as a remote web service. I’ve run into a snag in that I cannot figure out how to pass the --data-urlencode fields. I set up the edmunds remote web service on DreamFactory following the example and I am able to pass query parameters through that web service.

The curl example from Twilio’s site shows:

curl -X POST ‘https://api.twilio.com/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/Messages.json
–data-urlencode ‘To=+16518675309’
–data-urlencode ‘From=+14158141829’
–data-urlencode ‘Body=Hey Jenny! Good luck on the bar exam!’
-d ‘MediaUrl=http://farm2.static.flickr.com/1075/1404618563_3ed9a44a3a.jpg’
-u AC5ef872f6da5a21de157d80997a64bd33:[AuthToken]

For the -u field I set up under config in remote web services for CURL options CURLOPT_USERPWD with a value equal to AccountSid:AuthToken.

This seems to get passed through and if I run the curl command with no query parameters I get a response back from Twilio listing all the messages in my account. However, when I try to pass the query parameters I get an error message (“From number is required”).

This is the curl command which returns a list of messages from Twilio (i.e. it works):

curl -i -k -3 -X GET “http://localhost:8080/api/v2/twiliomsgs/
-H “X-DreamFactory-Api-Key:”
-H “X-DreamFactory-Session-Token:”

And this is the one which does not work:

curl -i -k -3 -X POST “http://localhost:8080/api/v2/twiliomsgs?To=%2B14152030606&From=%2B15103583700&Body=Hello
-H “X-DreamFactory-Api-Key:key”
-H “X-DreamFactory-Session-Token:token”

I also tried passing To, From, and Body via --data-urlencode instead of in the URL to DreamFactory as in the Twilio example but that did not work either.

I was wondering if anyone has set up Twilio or a similar service and has some suggestions to try.

I’m on DreamFactory 2.1.0.

For reference Twilio SMS REST API Docs

-Trevor

However, when I try to pass the query parameters I get an error message (“From number is required”).

tried used a %2B instead of the plus sign?

I mean "From=%2B14158141829" \ instead of 'From=+14158141829'

Hi - Good suggestion. Thanks! I tried that, but the To/From/Body parameters are still not getting passed through.

I think a super simple way to achieve this would be to use a custom server script - preferably php. You don’t really need to set up a remote web service or anything at all. You can call the custom script with the parameters, and upon execution it can return you a http status code, message etc. It should be pretty straightforward. There’s an example here which will help you understand how it works and probably you should be able to script something similar to send twilio messages in less than 30 mins :slight_smile: Let me know if you need any help with the script. Cheers