### Initialize and Use Tuya Cloud Library Source: https://github.com/aymkdn/tuyacloud-php/blob/master/README.md Demonstrates how to initialize the TuyaCloud library with API credentials and base URL, and then use it to get device status, send commands, retrieve scenes, and start a scene. Includes error handling for API requests. ```php 'https://openapi.tuyaeu.com', // URL API of Tuya 'accessKey' => 'nhepe4mrrtz8wju45mk3', // access key of your app 'secretKey' => 'sf94ryyrfvg3awvg4174m88wjpksytre', // access secret of your app ]; $tuya = new TuyaCloud($options); try { // to get the device status // you must pass the device_id $response = $tuya->getDevice('bfa18afnfyre87eb7ne0'); echo '
';
  print_r($response);
  echo '
'; // to send a command // you can pass a JSON string: '{"commands":[{"code":"switch_led","value":true}]}' // or a strClass object // or an array like the below one: $commands = [ "commands" => [ [ "code" => "switch_led", "value" => true ] ] ]; $response = $tuya->setDevice('bfa18afnfyre87eb7ne0', $commands); // we can retrieve all the scenes (including their id) $response = $tuya->getScenes(); echo '
';
  print_r($response);
  echo '
'; // and we can start a scene $response = $tuya->startScene('the_scene_id'); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ?> ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.