'; /** * initialize the UniFi API connection class and log in to the controller and do our thing */ try { $unifi_connection = new UniFi_API\Client( $controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion ); $set_debug_mode = $unifi_connection->set_debug($debug); $login_results = $unifi_connection->login(); $data = $unifi_connection->list_alarms(); /** * echo the results in JSON format */ echo json_encode($data, JSON_PRETTY_PRINT); } catch (CurlExtensionNotLoadedException $e) { echo 'CurlExtensionNotLoadedException: ' . $e->getMessage(). PHP_EOL; } catch (InvalidBaseUrlException $e) { echo 'InvalidBaseUrlException: ' . $e->getMessage(). PHP_EOL; } catch (InvalidSiteNameException $e) { echo 'InvalidSiteNameException: ' . $e->getMessage(). PHP_EOL; } catch (JsonDecodeException $e) { echo 'JsonDecodeException: ' . $e->getMessage(). PHP_EOL; } catch (LoginRequiredException $e) { echo 'LoginRequiredException: ' . $e->getMessage(). PHP_EOL; } catch (CurlGeneralErrorException $e) { echo 'CurlGeneralErrorException: ' . $e->getMessage(). PHP_EOL; } catch (CurlTimeoutException $e) { echo 'CurlTimeoutException: ' . $e->getMessage(). PHP_EOL; } catch (LoginFailedException $e) { echo 'LoginFailedException: ' . $e->getMessage(). PHP_EOL; } catch (Exception $e) { /** catch any other Exceptions that might be thrown */ echo 'General Exception: ' . $e->getMessage(). PHP_EOL; }