Skip to content

Instantly share code, notes, and snippets.

@jwood
Created June 25, 2012 13:56
Show Gist options
  • Save jwood/2988800 to your computer and use it in GitHub Desktop.
Save jwood/2988800 to your computer and use it in GitHub Desktop.
Sending Proby notifications using PHP
<?php
$PROBY_API_KEY = 'secret';
function do_post_request($url, $data, $headers) {
$postdata = http_build_query($data);
$header_string = "";
foreach ($headers as $key => $value) {
$header_string .= $key . ": " . $value . "\n";
}
$opts = array(
'http' => array(
'method' => 'POST',
'header' => $header_string,
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
}
function proby_send_start_notification($task_id) {
do_post_request("https://proby.signalhq.com/api/v1/tasks/$task_id/start.json",
null,
array('Content-Type' => 'application/json', 'api_key' => $GLOBALS['PROBY_API_KEY']));
}
function proby_send_finish_notification($task_id) {
do_post_request("https://proby.signalhq.com/api/v1/tasks/$task_id/finish.json",
null,
array('Content-Type' => 'application/json', 'api_key' => $GLOBALS['PROBY_API_KEY']));
}
proby_send_start_notification("your_task_id");
sleep(5);
proby_send_finish_notification("your_task_id");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment