[Freeswitch-users] CURL from Lua Script

Jai Rangi jprangi at didforsale.com
Fri Aug 5 04:00:13 MSD 2016


missing "=" in 3rd line.

*Jai Rangi*
Cebod Technologies LLC dba DIDforSale/Cebod Telecom
O 949-471-0102 | C 949-419-7634 <1-949-419-7634> | F 949-269-0449 /
949-232-1410 | jprangi at didforsale.com  www.cebod.com |  www.didforsale.com
|3200 Bristol St Suite 615, Costa Mesa, CA 92626  |






On Thu, Aug 4, 2016 at 4:31 PM, Don Hawkins <hawkins at hawkinsegroup.com>
wrote:

> So anytime I try to get a variable like UUID I always get  "attempt to
> call method 'getVariable' (a nil value)". It's calling the test.lua script
> at the right time but I've been unable to access a single variable so far.
> The phone is literally ringing at the time the script is called so I'm sure
> there is a session.
>
> test.lua looks like this (line 3 is the problem and line 2 has no value).
>
> api = freeswitch.API();
> local uuidto = event:getHeader("Unique-ID")
> local uuid session:getVariable("uuid")
> post_response = api:execute("curl", "http://voiceapi.cloud/API/
> callflow/test3.php?event=ringing&amp;uuid=.. uuidto ..")
>
>
> On Thu, Aug 4, 2016 at 5:35 PM, Abaci B <abaci64 at gmail.com> wrote:
>
>> you can do something like this.
>> local uuid = session:getVariable("uuid")
>> post_response = api:execute("curl", "http://myurl.com/test3.php?event=answer&uuid="
>> .. uuid)
>>
>> On Thu, Aug 4, 2016 at 6:25 PM, Don Hawkins <hawkins at hawkinsegroup.com>
>> wrote:
>>
>>> Sorry, one more question. How can I pass session/channel variables in
>>> the CURL request? ie. ${uuid}
>>>
>>> post_response = api:execute("curl", "http://myurl.com/test3.php?ev
>>> ent=answer&uuid=${uuid}")
>>>
>>>
>>> On Thu, Aug 4, 2016 at 5:21 PM, Don Hawkins <hawkins at hawkinsegroup.com>
>>> wrote:
>>>
>>>> mod_curl wasan't running, I overlooked that. Working fine now with the
>>>> API version.
>>>>
>>>>
>>>> On Thu, Aug 4, 2016 at 4:35 PM, Abaci B <abaci64 at gmail.com> wrote:
>>>>
>>>>> you can't run session:execute() if there is no active session. if you
>>>>> run it outside a call you can (for testing) maybe try running local
>>>>> session = freeswitch.Session() before running the curl
>>>>>
>>>>> On Thu, Aug 4, 2016 at 4:23 PM, Don Hawkins <hawkins at hawkinsegroup.com
>>>>> > wrote:
>>>>>
>>>>>> Tried the other way as well (without the API)
>>>>>>
>>>>>> session:execute("curl", "http://myurl.com/test3.php post
>>>>>> name=myname")
>>>>>> curl_response_code = session:getVariable("curl_response_code")
>>>>>> curl_response      = session:getVariable("curl_response_data")
>>>>>>
>>>>>> Getting this error:
>>>>>>
>>>>>> [ERR] mod_lua.cpp:203 /usr/share/freeswitch/scripts/test.lua:1:
>>>>>> attempt to index global 'session' (a nil value)
>>>>>> stack traceback:
>>>>>>         /usr/share/freeswitch/scripts/test.lua:1: in main chunk
>>>>>>
>>>>>>
>>>>>> On Thu, Aug 4, 2016 at 2:51 PM, Don Hawkins <
>>>>>> hawkins at hawkinsegroup.com> wrote:
>>>>>>
>>>>>>> root at debian:/usr/share/freeswitch/scripts# vi test.lua
>>>>>>>
>>>>>>> api = freeswitch.API();
>>>>>>> api:execute("curl", "http://myurl.com/test3.php post name1=value1")
>>>>>>>
>>>>>>>
>>>>>>> Snatched the code straight from the the example shown at the URL
>>>>>>> below. FS does execute the script but never reaches my URL with the POST
>>>>>>> request. Did I miss something?
>>>>>>>
>>>>>>> https://freeswitch.org/confluence/display/FREESWITCH/mod_curl
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sincerely,
>>>>>> Don Hawkins
>>>>>> CEO
>>>>>> Hawkins Enterprise Group LLC
>>>>>> http://hawkinsegroup.com
>>>>>> Zello PTT <http://zello.com>: push2don
>>>>>> P: 469-214-5044
>>>>>>
>>>>>> ____________________________________________________________
>>>>>> _____________
>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>> consulting at freeswitch.org
>>>>>> http://www.freeswitchsolutions.com
>>>>>>
>>>>>> Official FreeSWITCH Sites
>>>>>> http://www.freeswitch.org
>>>>>> http://confluence.freeswitch.org
>>>>>> http://www.cluecon.com
>>>>>>
>>>>>> FreeSWITCH-users mailing list
>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/free
>>>>>> switch-users
>>>>>> http://www.freeswitch.org
>>>>>>
>>>>>
>>>>>
>>>>> ____________________________________________________________
>>>>> _____________
>>>>> Professional FreeSWITCH Consulting Services:
>>>>> consulting at freeswitch.org
>>>>> http://www.freeswitchsolutions.com
>>>>>
>>>>> Official FreeSWITCH Sites
>>>>> http://www.freeswitch.org
>>>>> http://confluence.freeswitch.org
>>>>> http://www.cluecon.com
>>>>>
>>>>> FreeSWITCH-users mailing list
>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/free
>>>>> switch-users
>>>>> http://www.freeswitch.org
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sincerely,
>>>> Don Hawkins
>>>> CEO
>>>> Hawkins Enterprise Group LLC
>>>> http://hawkinsegroup.com
>>>> Zello PTT <http://zello.com>: push2don
>>>> P: 469-214-5044
>>>>
>>>
>>>
>>>
>>> --
>>> Sincerely,
>>> Don Hawkins
>>> CEO
>>> Hawkins Enterprise Group LLC
>>> http://hawkinsegroup.com
>>> Zello PTT <http://zello.com>: push2don
>>> P: 469-214-5044
>>>
>>> ____________________________________________________________
>>> _____________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
>
> --
> Sincerely,
> Don Hawkins
> CEO
> Hawkins Enterprise Group LLC
> http://hawkinsegroup.com
> Zello PTT <http://zello.com>: push2don
> P: 469-214-5044
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160804/993aa3cf/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list