【Defold】HTTP Requests する

Defold, DEVELOP

GET

local function handle_response(self, id, response)
    print(response.status, response.response)
end
 
http.request("https://www.defold.com", "GET", handle_response)

POST

local function handle_response(self, id, response)
    print(response.status, response.response)
end
 
local headers = {
    ["Content-Type"] = "application/x-www-form-urlencoded"
}
 
local body = "foo=bar"
http.request("https://httpbin.org/post", "POST", handle_response, headers, body)

余談

HTTP Request のテストに https://httpbin.org サービスが便利。

お知らせ

スポンサーリンク

Posted by kazupon