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
| <?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST,GET,OPTIONS");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: Origin,Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With,Access-Control-Allow-Credentials');
$url='https://stats.uptimerobot.com/api/getMonitor/28xBxu6Q9?m=778877453';
$method = 'GET';
//initiate CURL request
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
));
$timedeb = microtime(true);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
$duree = 1000*(microtime(true) - $timedeb);
$return = json_encode($err);
} else {
$duree = 1000*(microtime(true) - $timedeb);
$rep = json_decode($response, true, 512, 0);
//file_ecrit('debug.txt',$rep["monitor"]["logs"][0]["class"]);
// echo $rep["status"]; => OK !
$return = $rep["monitor"]["logs"][0]["class"];
$retour = [round($duree,0), $return];
echo json_encode($retour);
}
?> |
Partager