1. Go to this page and download the library: Download cmdrsharp/hetrixtools-api 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/ */
cmdrsharp / hetrixtools-api example snippets
// Example Uptime Monitor creation (adding a ping monitor to 8.8.8.8)
use CmdrSharp\HetrixtoolsApi\Uptime\Factory as HetrixTools;
$monitor = new HetrixTools('myApiKey');
try {
$result = $monitor->type('service')
->name('Greatest Monitor')
->target('8.8.8.8')
->timeout(10)
->frequency(1)
->failsBeforeAlert(1)
->public(false)
->showTarget(false)
->locations([
'dal' => true,
'msw' => true,
'nyc' => true
])->create();
} catch(\Exception $e) {
print($e->getMessage());
}
// Example Blacklist Monitor creation (adding a monitor to 192.168.0.0/24)
use CmdrSharp\HetrixtoolsApi\Blacklist\Factory as HetrixTools;
$monitor = new HetrixTools('myApiKey');
try {
$result = $monitor->target('192.168.0.0/24')
->label('Blacklist Monitor 1')
->contact(1)
->create();
} catch(\Exception $e) {
print($e->getMessage());
}
// Example Listing Uptime Monitors
use CmdrSharp\HetrixtoolsApi\Uptime\Repository as HetrixTools;
$instance = new HetrixTools('myApiKey');
try {
$result = $instance->listUptimeMonitors(); // Fetches 100 results
$result = $instance->listUptimeMonitors(0, 50); // Page 0, 50 results per page.
} catch(\Exception $e) {
print($e->getMessage());
}
// Example Blacklist Report
use CmdrSharp\HetrixtoolsApi\Blacklist\Repository as HetrixTools;
$instance = new HetrixTools('myApiKey');
try {
$result = $instance->blacklistReport('8.8.8.8');
$result = $instance->blacklistReport('8.8.8.8', '2018-03-29');
} catch(\Exception $e) {
print($e->getMessage());
}