curl -b ./cookies.txt -A "echoSensor" -F "json=true" -F "sn=yourDeviceNumber" -F "apikey=ff3f3275-f356-462a-7321-caf0b312fe02" -F "user=yourUsername" -F "pass=yourPassword" https://echosensor-server/api/
{
"type":"LIGHT",
"serial":"Z17795135172",
"value":"964",
"cpuTemperature":"16.67",
"latestTime":"13:47:33",
"latestDate":"2022/11/19"
}
964,53.33,14:10:59,2022/11/19,LIGHT
{
"Code":"Session",
"Type":"Auth.Error.x"
}
// create cookies file
$cookieFile = "./cookies.txt";
if(!file_exists($cookieFile)) {
$fh = fopen($cookieFile, "w");
fwrite($fh, "");
fclose($fh);
}
// set json true or false
$pars=array(
'json' => 'false',
'sn' => 'DEVICE_NUMBER',
'apikey' => 'ff3f3275-f356-462a-7321-caf0b312fe02',
'user' => 'YourUsername',
'pass' => 'YourPassword',
);
//step1
$curlSES=curl_init();
//step2
curl_setopt($curlSES,CURLOPT_URL,"https://sgneep.com/portaldata_api/");
curl_setopt($curlSES,CURLOPT_USERAGENT,"echosensorHeader");
curl_setopt($curlSES,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curlSES,CURLOPT_HEADER, false);
curl_setopt($curlSES, CURLOPT_POST, true);
curl_setopt($curlSES, CURLOPT_POSTFIELDS,$pars);
curl_setopt($curlSES, CURLOPT_COOKIESESSION, true); // Cookie
curl_setopt($curlSES, CURLOPT_COOKIEFILE, $cookieFile); // Cookie
curl_setopt($curlSES, CURLOPT_COOKIEJAR, $cookieFile); // Cookie
curl_setopt($curlSES, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curlSES, CURLOPT_TIMEOUT,30);
//step3
$result=curl_exec($curlSES);
//step4
curl_close($curlSES);
//step5
echo $result;
import requests
import http.cookiejar
#pip install requests
url = "https://echosensor-server/api/"
data = "sn=DEVICE_NUMBER&json=true&apikey=ff3f3275-f356-462a-7321-caf0b312fe02&user=YourUsername&pass=YourPassword"
headers = {'User-Agent': 'echosensor','Content-Type': 'application/x-www-form-urlencoded'}
cookies = http.cookiejar.MozillaCookieJar('cookies.txt')
cookies.load(ignore_expires=True)
r = requests.post(url, data=data, headers=headers, cookies=cookies)
print(r.text)
curl -b ./cookies.txt -A "echoSensor" -F "buffer=true" -F "json=null" -F "sn=yourDeviceNumber" -F "apikey=ff3f3275-f356-462a-7321-caf0b312fe02" -F "user=yourUsername" -F "pass=yourPassword" https://echosensor-server/api/
1065,18.33,16:10:22,2022/11/19,LIGHT
1115,18.33,16:11:09,2022/11/19,LIGHT
1186,53.33,16:12:00,2022/11/19,LIGHT
1092,17.22,16:12:46,2022/11/19,LIGHT
1087,17.78,16:13:30,2022/11/19,LIGHT
1077,17.22,16:14:17,2022/11/19,LIGHT
1155,17.22,16:15:13,2022/11/19,LIGHT
1040,17.78,16:16:00,2022/11/19,LIGHT
1079,17.78,16:17:12,2022/11/19,LIGHT
...
...
curl -b ./cookies.txt -A "echoSensor" -F "alarm=true" -F "json=null" -F "sn=yourDeviceNumber" -F "apikey=ff3f3275-f356-462a-7321-caf0b312fe02" -F "user=yourUsername" -F "pass=yourPassword" https://echosensor-server/api/
1065,15:53:57,2022/11/19,K32792135422,LIGHT
1049,15:54:50,2022/11/19,K32792135422,LIGHT
1011,15:55:37,2022/11/19,K32792135422,LIGHT
1041,15:56:36,2022/11/19,K32792135422,LIGHT
1063,15:57:31,2022/11/19,K32792135422,LIGHT
1046,15:58:15,2022/11/19,K32792135422,LIGHT
1063,15:59:00,2022/11/19,K32792135422,LIGHT
1045,15:59:44,2022/11/19,K32792135422,LIGHT
1072,16:00:38,2022/11/19,K32792135422,LIGHT
1042,16:01:59,2022/11/19,K32792135422,LIGHT
1023,16:02:48,2022/11/19,K32792135422,LIGHT
1030,16:03:51,2022/11/19,K32792135422,LIGHT
1103,16:05:05,2022/11/19,K32792135422,LIGHT
1060,16:05:55,2022/11/19,K32792135422,LIGHT
...
...
curl -b ./cookies.txt -A "echoSensor" -F "get_alarm=true" -F "json=true" -F "sn=yourDeviceNumber" -F "apikey=ff3f3275-f356-462a-7321-caf0b312fe02" -F "user=yourUsername" -F "pass=yourPassword" https://echosensor-server/api/
{
"status":"enabled",
"min":400,"max":2000
}
{
"Code":"User_Alarm",
"Type":"unknow"
}
{
"Code":"User_Alarm",
"Type":"unknow_data"
}