Last active
November 28, 2018 01:19
-
-
Save jeremyblaze/c84ac180cafc7ab7e4f4fdc3f7357922 to your computer and use it in GitHub Desktop.
Alerter middleman
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