-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathdemo_ping.php
40 lines (34 loc) · 927 Bytes
/
demo_ping.php
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
36
37
38
39
40
<?php
/**
* Minimal class autoloader
*
* @param string $class Full qualified name of the class
*/
function miniAutoloader(string $class)
{
$class = str_replace('\\', '/', $class);
require __DIR__ . '/../src/' . $class . '.php';
}
// If the Composer autoloader exists, use it. If not, use our own as fallback.
$composerAutoloader = __DIR__.'/../vendor/autoload.php';
if (is_readable($composerAutoloader)) {
require $composerAutoloader;
} else {
spl_autoload_register('miniAutoloader');
}
$deepLy = new ChrisKonnertz\DeepLy\DeepLy('');
$simple = (isset($_GET['simple']) and $_GET['simple'] == 1);
try {
$ping = $deepLy->ping();
if ($simple) {
echo '1';
} else {
echo 'Ping successful. Duration: ' . $ping . ' seconds';
}
} catch (\Exception $exception) {
if ($simple) {
echo '0';
} else {
echo 'Ping not successful. Could not reach API.';
}
}