Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Synology + Pushbullet
<?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
You can’t perform that action at this time.