I want to get some data from Shelly Device.
I have used this code so far, but the syntax is now deprecated.
This script works fine:
The new syntax is now:
I can't get it to work with curl.
The API is here: API, New syntax
I have used this code so far, but the syntax is now deprecated.
This script works fine:
PHP:
$key = '99999999';
$url = 'https://shelly-161-eu.shelly.cloud/device/status/?';
$device_id = '00082289c26e';
$data = http_build_query( [
"auth_key" => $key,
"id" => $device_id
] );
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-Type: application/x-www-form-urlencoded"] );
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, true);
print "<pre>";
print_r($result);
print "</pre>";
The new syntax is now:
Code:
curl -X POST 'https://<HOST>/v2/devices/api/get?auth_key=<AUTH_KEY>' \
-H 'Content-Type: application/json' \
-d '{"ids":["00082289c26e"],"select":["status","settings"],"pick":{"status":["sys"],"settings":["ble"]}}'
I can't get it to work with curl.
The API is here: API, New syntax