PHP
Send pings from PHP scripts using file_get_contents for simplicity or cURL for more control:
Simple — file_get_contents
<?php $pingUrl = 'https://watchcron.com/ping/your-uuid'; // Your work here processData(); // Ping on success file_get_contents($pingUrl);
With cURL and error handling
<?php function ping(string $url): void { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_exec($ch); curl_close($ch); } $pingUrl = 'https://watchcron.com/ping/your-uuid'; ping("$pingUrl/start"); try { processData(); ping($pingUrl); } catch (Exception $e) { ping("$pingUrl/fail"); throw $e; }
Using Guzzle
<?php use GuzzleHttp\Client; $client = new Client(['timeout' => 10]); $pingUrl = 'https://watchcron.com/ping/your-uuid'; $client->get("$pingUrl/start"); try { processOrders(); $client->get($pingUrl); } catch (Throwable $e) { $client->post("$pingUrl/fail", [ 'body' => $e->getMessage() ]); throw $e; }