<div dir="ltr">In browsing through the source to mod_curl, I found an option that allows me to use curl without invoking a shell. I made some minor changes to the script, changing the url to this:<div><br></div><div><div>url = "<a href="https://user:password@api.flowroute.com/v2/messages">https://user:password@api.flowroute.com/v2/messages</a>"</div></div><div><br></div><div>... adding some escaping after the message is composed...</div><div><br></div><div><div>message = message .. "."</div><div>-- Add JSON string escapes to the message</div><div>message = string.gsub(message, "([\\\"'])", "\\%1")</div></div><div><br></div><div>...and using the mod_curl API call to send the text to Flowroute:</div><div><br></div><div><div>api:execute("curl", url .. " content-type application/json post '" .. data .. "'")</div></div><div><br></div><div>Works, easy, efficient.</div><div><br></div><div>-- </div><div>Steve</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 2, 2016 at 3:26 PM, Steven Schoch <span dir="ltr"><<a href="mailto:schoch+freeswitch.org@xwin32.com" target="_blank">schoch+freeswitch.org@xwin32.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I got it working! The goal was to run a script to inform users via a text message when they get a voicemail.</div><div>This script looks for a "vm-notify-sms" param in the user's directory information. It sends the text from user's outbound caller-ID number, which is set in the standard FS configuration. I'm using the SMS API from Flowroute.com.</div><div><br></div><div>--[[ This script is called by configuration in autoload_configs/lua.conf.xml.</div><div> It is called on a "vm:maintenance" event.</div><div>]]</div><div><br></div><div>-- The following is specifc to the Flowroute SMS API,</div><div>-- documented at <a href="https://developer.flowroute.com/docs/messaging" target="_blank">https://developer.flowroute.com/docs/messaging</a></div><div>url = "<a href="https://api.flowroute.com/v2/messages" target="_blank">https://api.flowroute.com/v2/messages</a>"</div><div>authentication = "user:password"</div><span class=""><div><br></div><div>action = event:getHeader("VM-Action")</div><div>if action ~= "leave-message" then return end</div></span><span class=""><div>user = event:getHeader("VM-User")</div><div>domain = event:getHeader("VM-Domain")</div></span><span class=""><div>caller_id_name = event:getHeader("VM-Caller-ID-Name")</div><div>caller_id_number = event:getHeader("VM-Caller-ID-Number")</div></span><div>--[[ We don't care about these:</div><div>file_path = event:getHeader("VM-File-Path")</div><div>flags = event:getHeader("VM-Flags")</div><div>folder = event:getHeader("VM-Folder")</div><span class=""><div>uuid = event:getHeader("VM-UUID")</div></span><div>--]]</div><span class=""><div>message_len = event:getHeader("VM-Message-Len")</div></span><div>timestamp = event:getHeader("VM-Timestamp")</div><div>api = freeswitch.API();</div><div>from = api:execute("user_data", user .. "@" .. domain .. " var outbound_caller_id_number")</div><div>to = api:execute("user_data", user .. "@" .. domain .. " param vm-notify-sms")</div><div>if to == "" then return end</div><div><br></div><div>if caller_id_name == ''</div><div> or caller_id_name == 'UNKNOWN'</div><div> or caller_id_name == 'UNASSIGNED'</div><div> or caller_id_name == 'WIRELESS CALLER'</div><div> or caller_id_name == 'TOLL FREE CALL'</div><div> or caller_id_name == 'Anonymous'</div><div> or caller_id_name == 'Unavailable'</div><div> then caller_id_name = nil end</div><div>if caller_id_number == ''</div><div> then caller_id_number = nil end</div><div>message = "Voicemail "</div><div>if caller_id_name</div><div> then message = message .. "from " .. caller_id_name .. " (" .. caller_id_number .. ")"</div><div> elseif caller_id_number</div><div> then message = message .. "from " .. caller_id_number end</div><div>message = message .. " at " .. os.date("%I:%M %p", timestamp)</div><div>message = message .. " length " .. message_len .. " seconds"</div><div>message = message .. " to box " .. user</div><div>message = message .. "."</div><div>-- Blindly send the text</div><div>data = '{ "to": "' .. to .. '", "from": "' .. from .. '", "body": "' .. message .. '"}'</div><div>--[[</div><div> Until either Freeswitch has the ability to pass authentication data</div><div> to the mod_curl API (FS-9223), or the Flowroute API has the ability</div><div> to take authentication data in the POST body (they are working on it),</div><div> we are forced to spawn a shell to use the curl from our OS.</div><div>]]</div><div>-- api.execute("curl", url .. " auth " .. authentication .. " post " .. data)</div><div>os.execute("curl -u " .. authentication .. " -H 'Content-Type: application/json' -X POST -d '" .. data .. "' " .. url)</div><div><br></div></div></div></div>
</blockquote></div><br></div>