07.10.2022, 06:36
Use this as a starting point:
Post what you get in Logs tab.
Code:
require('socket.http')
require('ltn12')
require('json')
email = "username@email.com"
password = "password_here"
powerstation_id = "Portal_ID_here"
function encodepost(t)
local res = {}
local esc = require('socket.url').escape
for k, v in pairs(t) do
res[ #res + 1 ] = esc(k) .. '=' .. esc(v)
end
return table.concat(res, '&')
end
body = encodepost({
account = email,
pwd = password,
code = "",
})
headers = {
["sec-ch-ua"] = "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"99\", \"Microsoft Edge\";v=\"99\"",
["Accept"] = "application/json, text/javascript, */*; q=0.01",
["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8",
["X-Requested-With"] = "XMLHttpRequest",
["sec-ch-ua-mobile"] = "?0",
["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39",
["sec-ch-ua-platform"] = "\"Windows\"",
["Origin"] = "https://eu.semsportal.com",
["Sec-Fetch-Site"] = "same-origin",
["Sec-Fetch-Mode"] = "cors",
["Sec-Fetch-Dest"] = "empty",
["Referer"] = "https://eu.semsportal.com/home/login",
["Accept-Language"] = "en-GB,en;q=0.9,en-US;q=0.8",
["Content-Length"] = #body,
}
response = {}
res, code, hdrs, stat = socket.http.request({
url = "https://eu.semsportal.com/Home/Login",
method = "POST";
headers = headers,
source = ltn12.source.string(body),
sink = ltn12.sink.table(response),
})
log(res, code, hdrs, stat, response)