Created
November 29, 2016 14:54
-
-
Save sjelfull/a00a3658841679df1f0b0f1758ccdd58 to your computer and use it in GitHub Desktop.
Use Pushover and a webhook from Uptime Robot to send notifications to your phone
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 | |
require __DIR__ . '/vendor/autoload.php'; | |
use Sly\PushOver\Model\Push; | |
use Sly\PushOver\PushManager; | |
if (!isset($_GET['key']) || $_GET['key'] !== 'KEY') { | |
die('No key'); | |
} | |
$monitorFriendlyName = $_GET['monitorFriendlyName']; | |
$alertTypeFriendlyName = $_GET['alertTypeFriendlyName']; | |
$alertDetails = isset($_GET['alertDetails']) ? $_GET['alertDetails'] : null; | |
/** | |
* First, create your own push, with its message. | |
*/ | |
$myPush = new Push(); | |
$message = "$monitorFriendlyName: $alertTypeFriendlyName"; | |
if ($alertDetails) { | |
$message .= " — $alertDetails"; | |
} | |
$myPush->setMessage($message); | |
$myPush->setTitle('Uptime Robot'); // Optional | |
/** | |
* Create an instance for PushManager. | |
* Give it your user key (first arguement) and token one (second argument). | |
* You can give a device name on third argument (optional). | |
*/ | |
$pushManager = new PushManager('', ''); | |
/** | |
* Push it! :) | |
*/ | |
if ($mySentPushInformations = $pushManager->push($myPush)) { | |
/** | |
* Your message has been sent. | |
* $mySentPushInformations contents your sent push informations. | |
*/ | |
} | |
//monitorID=*monitorID*&monitorURL=*monitorURL*&monitorFriendlyName=*monitorFriendlyName*&alertType=*alertType*&alertTypeFriendlyName=*alertTypeFriendlyName*&alertDetails=*alertDetails*&monitorAlertContacts=*monitorAlertContacts* | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment