HTTPPost
The HTTPPost function sends an HTTP POST request to a specified URL with given data and headers. This function is useful for interacting with web services, APIs, and remote servers from within the game.
Parameters
url: The URL to which the POST request is sent.data: A table containing the data to be sent in the POST request.headers: A table containing the HTTP headers to be included in the POST request.
Example Usage in Lua
Here is an example of how to use the HTTPPost function in Lua:
local api = ...
local callback = function (status_code, data)
if status_code == 200 then
print ('Succesful')
print (data.message, data.expireDate, data.licenseName)
else
print ('Error when calling remote: ' .. status_code)
end
local http_headers = {
["API-KEY"] = "foo",
["X-Some-Header"] = "bar",
}
local currentSpec = GetSpecialization()
local id, spec, _, icon, role, stat = GetSpecializationInfo(currentSpec)
local class = select(7, GetSpecializationInfoByID(id))
spec = string.lower(spec)
class = string.lower(class)
local data_send = {
username = "John Doe",
password = "password",
authkey = "12345",
auth_key = "12345",
key = "exampleKey123",
spec = spec,
myclass = class,
}
local url = "https://someWebsite.com/auth_request"
api.HTTPPost(callback, url, data_send, http_headers)