PHP code example of diogodourado / ewelink-control-php

1. Go to this page and download the library: Download diogodourado/ewelink-control-php 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/ */

    

diogodourado / ewelink-control-php example snippets




iogodourado\Ewelink\EwelinkClient;
use Diogodourado\Ewelink\TokenManager;

$config = [
    'appId'       => 'SEU_APP_ID',
    'appSecret'   => 'SEU_APP_SECRET',
    'redirectUrl' => 'https://seu-dominio.com/ewelink/callback.php',
    'tokensFile'  => __DIR__ . '/tokens.json',
];



$client = new EwelinkClient($config);
$tm     = new TokenManager($config, $client);

// Exemplo: listar famílias
$familiesResp = $tm->withAccessToken(function (string $accessToken) use ($client) {
    return $client->getFamilies($accessToken);
});

var_dump($familiesResp['json']);
bash
composer