Skip to content

Instantly share code, notes, and snippets.

@jeremyblaze
Last active November 28, 2018 01:19
Show Gist options
  • Save jeremyblaze/c84ac180cafc7ab7e4f4fdc3f7357922 to your computer and use it in GitHub Desktop.
Save jeremyblaze/c84ac180cafc7ab7e4f4fdc3f7357922 to your computer and use it in GitHub Desktop.
Alerter middleman
<?php
if ( isset($_POST['message']) ) {
$url = 'https://api.pushover.net/1/messages.json';
$data = array();
$data['token'] = "YOUR PUSHOVER TOKEN";
$data['user'] = "YOUR PUSHOVER USER ID";
$data['message'] = $_POST['message'];
if ( isset($_POST['title']) ) {
$data['title'] = $_POST['title'];
} else {
$data['title'] = "Alert";
}
if ( isset($_POST['sound']) ) {
$data['sound'] = $_POST['sound'];
} else {
$data['sound'] = "pushover";
}
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo "Done";
} else {
die("No data");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment