尝试在Lua中将https字符串发送到网站

我在Lua中有点新手,我需要调用API。

“https://status.abc.com/integrations / plus /?endpoint =” .. number ..“&server =” .. server

这不是Json格式。 它只是将此http字符串发送到Web服务器。 实现这一点的最简单方法是什么?

点赞
用户12040044
用户12040044

尝试查看 LuaSec 库。 Lua 本身没有原生的 https 支持,所以你(据我所知)唯一的选择是构建 LuaSec 或尝试在互联网上找到一个构建版本。

2019-09-17 07:30:22
用户9819479
用户9819479
local ok =os.execute([[curl --cert /etc/openvpn/cert.crt --key /etc/openvpn/key.key -X POST -H 'Content-Type: application/x-www-form-urlencoded' 'url here' --data 'data here']])
local ok = os.execute([[curl --cert /etc/openvpn/cert.crt --key /etc/openvpn/key.key -X POST -H 'Content-Type: application/x-www-form-urlencoded' 'url here' --data 'data here']])

将上述 Lua 代码翻译成中文并保留原有的 Markdown 格式:

local ok = os.execute([[curl --cert /etc/openvpn/cert.crt --key /etc/openvpn/key.key -X POST -H 'Content-Type: application/x-www-form-urlencoded' 'url here' --data 'data here']])

此代码用于在 Lua 中执行 curl 命令,请求一个 URL 并将数据传递给它。其中,--cert--key 选项用于指定证书和密钥文件的位置,-X POST 选项声明请求方法为 POST,-H 选项设置请求头,--data 选项是发送给服务器的数据。os.execute 函数将 curl 命令作为参数执行,并将结果存储在变量 ok 中。

2019-09-18 17:05:54