private function performAPICall($url, $data = array()) { //Set configuration settings $config = ['apiKey' => $this->app["config"]["monitoring"]["apikey"], 'url' => 'http://api.uptimerobot.com']; try { $api = new API($config); $results = $api->request($url, $data); $this->dialogProvider->logConfig("Sent a call to " . $url . " and got a response: " . print_r($results, true)); return $results; } catch (\Exception $e) { $this->dialogProvider->logConfig("Sent a call to " . $url . " and got an error: " . $e->getMessage()); } }
<?php ini_set('display_errors', '1'); /* @Author: Adam Matthews @Date: 20/10/14 Uptime Robot API Scripts API forked from ckdarby/PHP-UptimeRobot */ require_once 'UptimeRobot/config.php'; use UptimeRobot\API; try { //Initalizes API with config options $api = new API($config); //Define parameters for our getMethod request $args = ['showTimezone' => 1, 'customUptimeRatio' => '1-7-30']; //Makes request to the getMonitor Method $results = $api->request('/getMonitors', $args); //Output json_decoded contents //var_dump($results); } catch (Exception $e) { echo $e->getMessage(); //Output various debug information var_dump($api->debug); } // Get Overall Uptime Stats for day, week, month and all time. function getOverall($results) { //blank vars $day = 0; $week = 0;