Adsar Logo


Soliscloud PHP implementation



For those with solar panels, some providers utilise SolisCloud to manage your installation.

If you want to grab your stats using PHP, once you've grabbed your API key & secret, you can use the code below (modified from https://github.com/hultenvp/solis-sensor/issues/18)...

<?php
$keyID = 'xxxxxx';
$keySecret = 'xxxxxx';

$body = '{"pageNo":1,"pageSize":10}';

$contentMD5 = base64_encode(md5($body, true));

$contentType = "application/json";
$endPoint = "/v1/api/userStationList";

$gmdate = gmdate("D, j M Y H:i:s") . " GMT";

$cadena = "POST\n{$contentMD5}\n{$contentType}\n{$gmdate}\n{$endPoint}";
$signature = base64_encode(pack('H*',hash_hmac('sha1', $cadena , $keySecret, false)));

$authorization = "API_" . $keyID . ":" . $signature;

$curl = curl_init();

$headers = array(
'Content-MD5: ' . $contentMD5,
'Authorization: ' . $authorization,
'Content-Type: ' . $contentType,
'Date: ' . $gmdate
);

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.soliscloud.com:13333/v1/api/userStationList',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => $headers,
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

You can also get more details at the inverter level by running the following:

<?php
$keyID = 'xxxxxx';
$keySecret = 'xxxxxx';

$body = '{"pageNo":1,"pageSize":10}';

$contentMD5 = base64_encode(md5($body, true));

$contentType = "application/json";
$endPoint = "/v1/api/inverterList";

$gmdate = gmdate("D, j M Y H:i:s") . " GMT";

$cadena = "POST\n{$contentMD5}\n{$contentType}\n{$gmdate}\n{$endPoint}";
$signature = base64_encode(pack('H*',hash_hmac('sha1', $cadena , $keySecret, false)));

$authorization = "API_" . $keyID . ":" . $signature;

$curl = curl_init();

$headers = array(
    'Content-MD5: ' . $contentMD5,
    'Authorization: ' . $authorization,
    'Content-Type: ' . $contentType,
    'Date: ' . $gmdate
  );

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://www.soliscloud.com:13333'.$endPoint,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  //CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $body,
  CURLOPT_HTTPHEADER => $headers,
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Trees for life


Want to get in touch? mail@adsar.co.uk