Lua-cURL

shinoa

Известный
Автор темы
297
206
cURL для moonloader, содержимое архива распаковать в папку с игрой: https://www.upload.ee/files/14409798/build.zip.html
Примеры:
GET:
local cURL = require("lcurl")

local body = {}

cURL.easy()
  :setopt_url("http://jsonplaceholder.typicode.com/posts/1")
  :setopt_writefunction(table.insert, body)
  :perform()
:close()

print(table.concat(body))
--[[output
 {
  "userId": 1,
  "id": 1,
  "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
  "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}]]
POST:
local cURL = require("lcurl")

local body = {}

cURL.easy()
  :setopt_url("http://jsonplaceholder.typicode.com/posts")
  :setopt_postfields('foo=bar')
  :setopt_writefunction(table.insert, body)
  :perform()
:close()

body = table.concat(body)
print(body)

--[[output
 {
  "foo": "bar",
  "id": 101
}]]

Отправка файла:
POST:
local cURL = require("lcurl")

local post = cURL.form()
  :add_file("text", "D:/Game/moonloader/test.txt", "text/plain")

cURL.easy()
  :setopt_url(url)
  :setopt_httppost(post)
  :perform()
:close()

Больше примеров и документации: https://github.com/Lua-cURL/Lua-cURLv3
thx @SR_team