PHP code example of revolution / laravel-switchbot
1. Go to this page and download the library: Download revolution/laravel-switchbot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
revolution / laravel-switchbot example snippets
use Illuminate\Support\Facades\Http;
$response = Http::switchbot()->get('devices');
dump($response->json());
$deviceId = $response->json('body.deviceList.0.deviceId');
if (filled($deviceId)) {
$response = Http::switchbot()->get("devices/$deviceId/status");
dump($response->json());
}
use Illuminate\Support\Facades\Http;
$response = Http::switchbot()->get('scenes');
dump($response->json());