[Freeswitch-users] Execute HTTP request from LUA script not work

Jurijs Ivolga jurijs.ivolga at gmail.com
Wed Aug 22 06:22:10 UTC 2018


Hi,

I'm doing in following way:

> function postbla(bla)
>
>
> local body =
> [[
> {
>             "bla": "]]..bla..[["
> }
> ]]
>
> path = pathzzz .. "postbla"
>
> c = curl.easy{
>   url        = path,
>   post       = true,
>   httpheader = {
>     "Content-Type: application/json";
>   };
>   postfields = body;
> }
>
>
>  c:perform{
>         writefunction = function(s)
>             res = s
>         end
>     }
>
> statuscode = c:getinfo_response_code()
>
> return statuscode, res, body
>
> end
>

Jurijs


On Tue, Aug 21, 2018 at 11:19 PM Jose David Jurado Alonso <
josedavid at zennio.com> wrote:

> Thank you very much David, if you find the script it would be a great help.
>
> I have been on vacation and I have not been able to try much more in this time.
>
> 2018-08-03 20:07 GMT+02:00 David Villasmil <david.villasmil.work at gmail.com
> >:
>
>> Oh this took me some time to figure out, i'll dig up ny script and share
>> it with you.
>>
>> On Fri, Aug 3, 2018, 13:16 Jose David Jurado Alonso <josedavid at zennio.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I have tried to make a HTTP POST request from LUA  script but it does
>>> not work correctly in any way.
>>>
>>> This is an example of the errors that I have obtained:
>>>
>>> 09802b39-524f-4011-ada7-418e6a870248 2018-08-03 12:23:07.981581 [ERR]
>>> mod_lua.cpp:203 error loading module socket.core from file
>>> /usr/local/lib/lua/5.1/socket/core.so:
>>> 09802b39-524f-4011-ada7-418e6a870248 /usr/local/lib/lua/5.1/socket/core.so:
>>> undefined symbol: lua_pcall
>>> 09802b39-524f-4011-ada7-418e6a870248 stack traceback:
>>> 09802b39-524f-4011-ada7-418e6a870248 [C]: in ?
>>> 09802b39-524f-4011-ada7-418e6a870248 [C]: in function require
>>> 09802b39-524f-4011-ada7-418e6a870248 /usr/local/share/lua/5.1/socket.lua:12:
>>> in main chunk
>>> 09802b39-524f-4011-ada7-418e6a870248 [C]: in function require
>>> 09802b39-524f-4011-ada7-418e6a870248 /usr/local/share/lua/5.1/socket/http.lua:10:
>>> in main chunk
>>> 09802b39-524f-4011-ada7-418e6a870248 [C]: in function require
>>> 09802b39-524f-4011-ada7-418e6a870248 /usr/share/freeswitch/scripts/test.lua:3:
>>> in main chunk
>>>
>>>
>>>
>>> The lua script is:
>>>
>>> local http = require "socket.http";
>>>
>>> local req_url = "http://localhost/"
>>>
>>> http.request{
>>>   url = req_url,
>>>   method = "POST"
>>> }
>>>
>>>
>>>
>>> I tried several tutorials and several configurations:
>>>
>>>
>>>    -
>>>    https://freeswitch.org/confluence/display/FREESWITCH/Installing+LuaSocket
>>>    -
>>>    https://freeswitch.org/confluence/display/FREESWITCH/Third+Party+Libraries
>>>     with  https://luarocks.org/modules/jakeg/lua-requests
>>>    <https://luarocks.org/modules/jakeg/lua-requests>
>>>
>>> And some other things that I do not remember but always fail for some
>>> "undefined symbol".
>>>
>>> Any ideas? Thanks!
>>>
>>> José D.
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Services
>>> sales at freeswitch.com
>>> https://freeswitch.com
>>>
>>> Official FreeSWITCH Sites
>>> https://freeswitch.com/oss
>>> https://freeswitch.org/confluence
>>> https://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
>>> https://freeswitch.com
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Services
>> sales at freeswitch.com
>> https://freeswitch.com
>>
>> Official FreeSWITCH Sites
>> https://freeswitch.com/oss
>> https://freeswitch.org/confluence
>> https://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
>> https://freeswitch.com
>>
>
> _________________________________________________________________________
> Professional FreeSWITCH Services
> sales at freeswitch.com
> https://freeswitch.com
>
> Official FreeSWITCH Sites
> https://freeswitch.com/oss
> https://freeswitch.org/confluence
> https://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
> https://freeswitch.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20180822/61a6d13f/attachment-0001.html>


More information about the FreeSWITCH-users mailing list