Answer the question
In order to leave comments, you need to log in
What is the purpose of the http.Fetch and http.Post commands?
I work here with PHP (namely with the scripts themselves), but the request itself and the result itself come from the LUA script. I'm not familiar with it, so I'm asking you a question. Help me explain exactly how these commands work: http.Fetch and http.Post . Here are code examples:
http.Fetch("http://metrostroi.net/api/mag_bans/",function(body,len,headers,code)
metadmin.MAG = util.JSONToTable(body)
end)
timer.Create("MAG",5*60,0,function()
http.Fetch("http://metrostroi.net/api/mag_bans/",function(body,len,headers,code)
metadmin.MAG = util.JSONToTable(body)
for k,v in pairs(metadmin.MAG) do
local target = player.GetBySteamID(v.steamid)
if target then
target:Kick("MAG banned from secure server")
end
end
end)
end)
if metadmin.api_key then
metadmin.print("Проверка АПИ ключа")
local time = os.time()
local hash = metadmin.sha256(GetConVar("hostport"):GetString()..tostring(time)..metadmin.api_key)
http.Post("http://metrostroi.net/api/key_check",{port=GetConVar("hostport"):GetString(),date=tostring(time),hash=hash},
function(body,len,headers,code)
if body != "ok" then
local str = "АПИ ключ не прошел проверку. ("..body..")"
metadmin.print(str,true)
metadmin.Log(str)
metadmin.api_key = false
SetGlobalBool("metadmin.partner",false)
else
SetGlobalBool("metadmin.partner",true)
metadmin.print("АПИ ключ прошел проверку.")
end
end
)
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question