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.

Rewrite Curl to LUA?
#1
Hello,

Can anyone tell me if this sample script can be "transplanted" to LM?

Code:
<?php
$username = 'xxx@xxx.xxx';
$password = 'xxx;
$serial = 'xxx';
$nonce;
$jsessionid;
$token;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/user/init";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
echo "cURL Error #:" . $err;
}
else
{
$json = json_decode($response, true);
$nonce = $json['nonce'];
$jsessionid = $json['jsessionid'];
$password = sha1($password);
$token = $nonce . $password;
$token = sha1($token);
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/user/login?token=$token&username=$username";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"cookie: JSESSIONID = $jsessionid;"    
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
echo "cURL Error #:" . $err;
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/box/reboot/$serial";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"cookie: JSESSIONID = $jsessionid;"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
echo "cURL Error #:" . $err;
}
else
{
echo 'success';
}
?>

If yes, can you give some guidance if not the full code?
I'm using ZipaTile as room thermostat (and lights, Sonos, etc. UI ), but sometimes it fails to send temperature data. The idea is to check periodically the group update time from resident script, and if it is to long issue a reboot command.

Thanks, Z
Reply


Messages In This Thread
Rewrite Curl to LUA? - by zoltan - 14.09.2017, 15:14
RE: Rewrite Curl to LUA? - by admin - 15.09.2017, 07:37
RE: Rewrite Curl to LUA? - by zoltan - 15.09.2017, 16:01
RE: Rewrite Curl to LUA? - by DGrandes - 21.08.2018, 08:38
RE: Rewrite Curl to LUA? - by admin - 21.08.2018, 12:06
RE: Rewrite Curl to LUA? - by DGrandes - 22.08.2018, 07:24

Forum Jump: