-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
35 lines (26 loc) · 823 Bytes
/
example.php
File metadata and controls
35 lines (26 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once __DIR__ . '/src/Exceptions/CheckHostException.php';
require_once __DIR__ . '/src/CheckHost.php';
use CheckHostCc\CheckHostApi\CheckHost;
try {
$api = new CheckHost();
echo "Fetching my ip...\n";
$ip = $api->myip();
print_r($ip);
echo "\nFetching locations short count...\n";
$locations = $api->locations();
echo "Active nodes: " . count($locations) . "\n";
echo "\nPinging 8.8.8.8...\n";
$ping = $api->ping('8.8.8.8', ['region' => ['EU']]);
print_r($ping);
if (isset($ping['uuid'])) {
echo "\nWaiting 2 seconds before report...\n";
sleep(2);
$report = $api->report($ping['uuid']);
print_r($report);
}
echo "\nAll basic tests passed.\n";
}
catch (\Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}