PHP code example of kukkjanos / ewelink
1. Go to this page and download the library: Download kukkjanos/ewelink 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/ */
kukkjanos / ewelink example snippets
ons = [
'auth' => [
'email' => 'eWelink login email',
//'phone' => '+361234567', # email or phone login parameter
'password' => 'eWelink login password',
'region' => 'eu'
],
'settings' => [
'cachedir' => './cache', // Token cache directory
'cachetime' => 3600, // The expiration time, defaults to 3600
]
];
// Init configuration
$config = new EWeLink\Api\Config($options);
// Init API
$api = new EWeLink\Api\EWeApi($config);
// All device
print_r( $api->getDevices() );
// One device
$deviceId = 'xyz';
print_r( $api->getDevice($deviceId) );
// Toogle device
//print_r( $api->toggleDevice($deviceId) );