<?php /** * Example of Netatmo Welcome API * For further information, please take a look at https://dev.netatmo.com/doc */ define('__ROOT__', dirname(dirname(__FILE__))); require_once __ROOT__ . '/src/Clients/NAWelcomeApiClient.php'; require_once 'Config.php'; require_once 'Utils.php'; $scope = NAScopes::SCOPE_READ_CAMERA; //Client configuration from Config.php $conf = array("client_id" => $client_id, "client_secret" => $client_secret, "username" => $test_username, "password" => $test_password, "scope" => $scope); $client = new NAWelcomeApiClient($conf); //Retrieve access token try { $tokens = $client->getAccessToken(); } catch (NAClientException $ex) { $error_msg = "An error happened while trying to retrieve your tokens \n" . $ex->getMessage() . "\n"; handleError($error_msg, TRUE); } //Try to retrieve user's Welcome information try { //retrieve every user's homes and their last 10 events $response = $client->getData(NULL, 10); $homes = $response->getData(); } catch (NASDKException $ex) { handleError("An error happened while trying to retrieve home information: " . $ex->getMessage() . "\n", TRUE); } if (is_null($homes) || empty($homes)) { handleError("No home found for this user...", TRUE); }