curl -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"
}
// 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_CONNECTTIMEOUT,10);
curl_setopt($curlSES, CURLOPT_TIMEOUT,30);
//step3
$result=curl_exec($curlSES);
//step4
curl_close($curlSES);
//step5
echo $result;
import requests
#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'}
r = requests.post(url, data=data, headers=headers)
print(r.text)