Skip to content

Instantly share code, notes, and snippets.

@rtekie
Created August 26, 2012 03:27
Show Gist options
  • Select an option

  • Save rtekie/3473562 to your computer and use it in GitHub Desktop.

Select an option

Save rtekie/3473562 to your computer and use it in GitHub Desktop.
PHP example of using API to notify CronSentry upon a job completion
<?php
// PHP example of using API to notify CronSentry upon a job completion
// For API documentation please go to http://www.cronsentry.com/help#api
// set POST variables
$url = 'http://api.cronsentry.com/api/v1/notifications';
$parameters = array(
'api_key' => 'YOUR_API_KEY',
'job_name' => urlencode('Your job name'),
'status' => 1,
'message' => urlencode('Please change me')
);
// do POST
$c = curl_init();
curl_setopt($c,CURLOPT_URL, $url);
curl_setopt($c,CURLOPT_POST, true);
curl_setopt($c,CURLOPT_POSTFIELDS, $parameters);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($c);
curl_close($c);
// check response
echo "response=".$response."\n";
$parsed_response = json_decode($response, true);
var_dump($parsed_response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment