Created
May 30, 2015 00:17
-
-
Save ghostbitmeta/2b0d089a9ee2d88cdb5f to your computer and use it in GitHub Desktop.
Synology + Pushbullet
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 | |
// Used code from the following sources: | |
// https://gist.github.com/styxit/e34d4c6f8cb23d55f5af#file-synology-pushover-php | |
// http://pastebin.com/iHAFAHGq | |
// Thanks to: https://styxit.com/2014/05/10/synology-pushover.html | |
// Only allow request made by localhost? | |
// Set this to false if this script is not running on your synology webserver (less secure) | |
$localOnly = true; | |
echo time(); | |
// Validate httpHost and/or remote addr? | |
if ($localOnly) { | |
if ($_SERVER['HTTP_HOST'] != 'localhost') { | |
// Not locahost | |
die; | |
} | |
} | |
// Open curl connection | |
$ch = curl_init(); | |
// Set variables from user input | |
$postdata = json_encode([ | |
"type" => "note", | |
"title" => isset($_GET['text']) ? $_GET['text'] : false, | |
"body" => isset($_GET['text']) ? $_GET['text'] : false, | |
]); | |
$token = $_GET['appkey']; | |
// Prepare HTTP header for authentication | |
$header = array(); | |
$header[] = "Authorization: Bearer " . $token; | |
$header[] = "Content-Type: application/json"; | |
// Set the url, number of POST vars, POST data | |
curl_setopt($ch,CURLOPT_URL, "https://api.pushbullet.com/v2/pushes"); | |
curl_setopt($ch,CURLOPT_HTTPHEADER, $header); | |
curl_setopt($ch,CURLOPT_POST, 1); | |
curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata); | |
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); | |
// Execute post | |
$result = curl_exec($ch); | |
curl_close($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment