HTTP
HTTP:Request(options)
Places a new HTTP Request in the Queue
[REQUIRED]urlis the request full url string[REQUIRED]methodcan be any string akaGET,PUT,POST,OPTIONS,NilNAmE[optional]callbackis a function to be called after theRequestcompletes.[optional]headersis a table of string values to put as headers on the request[optional]paramsare the requestbodyused by everymethodbesidesGET[optional]pinis a CERTPIN string
local function httpCallback(status,result)
print(status,result)
end
local request = {
callback = httpCallback,
method = "POST",
params = "request body goes here",
url = "https://google.com",
headers = {"Accept: application/json", "Content-Type: application/x-www-form-urlencoded"},
pin = "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno="
}
HTTP:Request(request)
Deprecated
HTTP:GET(url, [params,] callBack)
Places a GET call to a HTTP API.
** Other variables are permitted, if you have specific questions, ask an admin.
local url = 'https://someApi.com'
local headers = {"Accept: application/json", "Content-Type: application/x-www-form-urlencoded"}
local function callback(status, data)
if status == 200 then
print ('Success! Your data is as follows:')
print (data)
else
print ('Failure code:', status)
end
end
HTTP:GET(url, headers, callBack)
HTTP:POST(url, postData, callBack)
Place a POST call to a HTTP API.
** Other varaibles are permitted, if you have specific questions, ask an admin.
local url = 'https://httpbin.org/post?clue=yes&something=no'
local postData = "token: '1234567890abc', username: 'JackBauer'"
local function callback(status, data)
if status == 200 then
print ('Success! Your data is as follows:')
print (data)
else
print ('Failure code:', status)
end
end
HTTP:POST(url, postData, callback)