lostfields / python-panasonic-comfort-cloud

A python module for reading and changing status of panasonic climate devices through Panasonic Comfort Cloud app api
MIT License
69 stars 40 forks source link

PHP OR JS #69

Closed itvitacredit closed 2 years ago

itvitacredit commented 2 years ago

Hello May be there is in PHP or JS ? Or May be Document for REST API ?

itvitacredit commented 2 years ago

Not working

$params = array(
  "language" => "0",
  "loginId" => "$login",
  "password" => "$password",
);

$params=json_encode($params);

$headers = array(
  "X-APP-TYPE: 1",
  "X-APP-VERSION: 2.20.0",
  "User-Agent: G-RAC",
  "Accept: application/json",
  "Content-Type: application/json;"
     );

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://accsmart.panasonic.com/auth/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HEADER, TRUE); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
$response=json_decode($response, true);

print_r($response);
itvitacredit commented 2 years ago

Answer for php

function CCLogin($login, $password){ $params = array( "language" => "0", "loginId" => "$login", "password" => "$password", ); $params=json_encode($params);

$headers = array(
"User-Agent: G-RAC",
"Accept-Encoding: gzip, deflate",
"Accept: application/json; charset=utf-8",
"Connection: keep-alive",
"X-APP-TYPE: 1",
"X-APP-VERSION: 1.19.0",
"Content-Type: application/json; charset=utf-8"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://accsmart.panasonic.com/auth/login");
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HEADER, 0);    
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
$response=json_decode($response);
return $response;

}

lostfields commented 2 years ago

This library is for Python, but it's possible to make it work elsewhere as well.

You may try to download VS Code and try to run some of the requests in https://github.com/lostfields/python-panasonic-comfort-cloud/blob/master/requests.http - you may use curl as well, but you have to rewrite them.

VS Code + REST Client will run these commands in sequence.

First login, by running the first request. Then run the second one to get the first device in the device list. After that you can run anyone of them, to see how it works