Created
August 21, 2017 15:17
-
-
Save jeremyblaze/da3ca042a186d418950ed87d5bcb0cd3 to your computer and use it in GitHub Desktop.
Alerter
This file contains 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 | |
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'); | |
?> |
This file contains 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 | |
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