Forked from MarijnKoesen/sendPushoverNotification.php
Created
August 11, 2013 03:38
-
-
Save justyns/6203282 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/php | |
<?php | |
/** | |
* Zabbix notification script, used to send zabbix notifications via pushover | |
* to smartphones like an SMS. | |
* | |
* Usage: sendPushoverNotification <pushover-user-key> <subject> <message> | |
* @author Marijn Koesen | |
* @version 0.1 | |
*/ | |
define('PUSHOVER_APP_TOKEN', 'SET_ME_WITH_YOUR_OWN_APP_TOKEN'); // Your 'Zabbix' app token from Pushover | |
if ($argc != 4) { | |
die("Usage: {$argv[0]} <pushover-user-key> <subject> <message>\n"); | |
} | |
list($program, $to, $subject, $message) = $argv; | |
$ch = curl_init(); | |
curl_setopt_array($ch, array( | |
CURLOPT_URL => 'https://api.pushover.net/1/messages.json', | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_POSTFIELDS => array( | |
'token' => PUSHOVER_APP_TOKEN, // the pushover app token | |
'user' => $to, // the pushover user token | |
'message' => $subject . ': ' . $message, | |
) | |
)); | |
$result = json_decode(curl_exec($ch), 1); | |
curl_close($ch); | |
if (!isset($result['status']) || $result['status'] != 1) { | |
echo 'ERROR: could not send message, pushover said: "' . implode(', ', $result['errors']) . '"' . "\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment