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);
}
printMessageWithBorder("User's Homes");
foreach ($homes as $home) {
    printHomeInformation($home);
}
$home = $homes[0];
$tz = $home->getTimezone();
if (!empty($home->getPersons())) {
    $known = $home->getKnownPersons();