Skip to content

Instantly share code, notes, and snippets.

@ety001
Last active August 26, 2019 08:46
Show Gist options
  • Save ety001/23d5524d911c70de08951ef003d83012 to your computer and use it in GitHub Desktop.
Save ety001/23d5524d911c70de08951ef003d83012 to your computer and use it in GitHub Desktop.
cybex watch dog
<?php
function postData($url, $data) {
$options = array(
'http' =>
array(
'header' => "Content-Type: application/json\r\n".
"Content-Length: ".strlen($data)."\r\n",
'method' => 'POST',
'content' => $data,
)
);
$context = stream_context_create($options);
try {
$result = file_get_contents($url, false, $context);
$r = json_decode($result, true);
$result = $r['result'];
} catch (\Exception $e) {
return false;
}
return $result;
}
$last = 0;
while (1) {
$r = postData('https://apihk.cybex.io', '{"jsonrpc":"2.0","method":"get_witness_by_account","params":["1.2.51855"],"id":1}');
$total_missed = $r['total_missed'];
if ($last < $total_missed) {
$t = file_get_contents('https://api.telegram.org/bot<token>/sendMessage?chat_id=275323482&text=lost%20block--'.$total_missed);
}
$last = $total_missed;
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment