Created
August 26, 2012 03:27
-
-
Save rtekie/3473562 to your computer and use it in GitHub Desktop.
PHP example of using API to notify CronSentry upon a job completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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