点赞
用户4984564
用户4984564

你有很多选择

这些选项都有一些不同,但是它们都可以调用你的 API 端点。

2019-11-14 07:35:09
用户8062151
用户8062151

Lua by itself cannot call that endpoint, since the standard networking doesn't support https. You will need to use a 3rd-party library, I suggest Lua-cURL. You will need to download and install it.

Lua 本身无法调用该端点,因为标准网络不支持 https。你需要使用第三方库,我建议使用 Lua-cURL。你需要下载并安装它。

2019-11-14 18:49:43
用户52499
用户52499

使用 luasocket

local http = require('socket.http')
local ltn12 = require('ltn12')

local r = {}
http.request {
    url = 'https://blockchain.info/tobtc?currency=USD&value=1000000',
    headers = {['x-accept'] = 'donates'},
    sink = ltn12.sink.table(r)
}
print(r[1])

将以上 Lua 代码使用 luasocket 库发送 HTTPS 请求,并将响应打印输出。

2021-01-18 23:54:04