Skip to content

Instantly share code, notes, and snippets.

@sjelfull
Created November 29, 2016 14:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjelfull/a00a3658841679df1f0b0f1758ccdd58 to your computer and use it in GitHub Desktop.
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
<?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