Skip to content

Instantly share code, notes, and snippets.

@jeremyblaze
Created August 21, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyblaze/da3ca042a186d418950ed87d5bcb0cd3 to your computer and use it in GitHub Desktop.
Save jeremyblaze/da3ca042a186d418950ed87d5bcb0cd3 to your computer and use it in GitHub Desktop.
Alerter
<?php
function alertMe($message, $sound = "pushover") {
$data['message'] = $message;
$data['title'] = "THE TITLE OF YOUR APP";
$data['sound'] = $sound;
$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("THE LINK TO YOUR MIDDLEMAN", false, $context);
}
alertMe('This is just an example', 'cashregister');
?>
<?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