This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Goodwe
#4
Try this:
Code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
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), }) cookie = hdrs['set-cookie'] if cookie then   headers["Cookie"] = cookie:split(';')[1] end headers["Referer"] = "https://eu.semsportal.com/PowerStation/PowerStatusSnMin/" .. powerstation_id log(res, code, hdrs, stat, response) body = encodepost({   str = json.encode({     api = "v1/PowerStation/GetMonitorDetailByPowerstationId",     param = {       powerStationId = powerstation_id     }   }) }) response = {} res, code, hdrs, stat = socket.http.request({   url = "https://eu.semsportal.com/GopsApi/Post?s=v1/PowerStation/GetMonitorDetailByPowerstationId",   method = "POST",   headers = headers,   source = ltn12.source.string(body),   sink = ltn12.sink.table(response), }) log(res, code, hdrs, stat, response)
Reply


Messages In This Thread
Goodwe - by Danny - 06.10.2022, 13:34
RE: Goodwe - by admin - 07.10.2022, 06:36
RE: Goodwe - by Danny - 07.10.2022, 07:06
RE: Goodwe - by admin - 07.10.2022, 08:31
RE: Goodwe - by Danny - 07.10.2022, 10:33
RE: Goodwe - by admin - 07.10.2022, 10:44
RE: Goodwe - by admin - 10.10.2022, 10:07
RE: Goodwe - by Danny - 10.10.2022, 12:10
RE: Goodwe - by pioneersteffen - 07.01.2023, 19:35
RE: Goodwe - by pioneersteffen - 04.06.2023, 11:03
RE: Goodwe - by admin - 05.06.2023, 06:13
RE: Goodwe - by pioneersteffen - 10.06.2023, 07:53
RE: Goodwe - by Amelie - 13.06.2023, 18:28
RE: Goodwe - by admin - 14.06.2023, 07:02
RE: Goodwe - by Amelie - 17.06.2023, 13:48
RE: Goodwe - by admin - 19.06.2023, 08:04
RE: Goodwe - by Amelie - 19.06.2023, 19:29
RE: Goodwe - by admin - 20.06.2023, 07:10
RE: Goodwe - by Amelie - 23.06.2023, 11:20
RE: Goodwe - by admin - 26.06.2023, 08:59

Forum Jump: