Skip to content

Instantly share code, notes, and snippets.

@gyengus
Created July 25, 2015 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyengus/1e1cb2a697dab07ab9bb to your computer and use it in GitHub Desktop.
Save gyengus/1e1cb2a697dab07ab9bb to your computer and use it in GitHub Desktop.
Pushbullet gateway
<?php
$title = "";
if (isset($_POST['title'])) $title = $_POST['title'];
$text = "";
if (isset($_POST['text'])) $text = $_POST['text'];
$dest = "";
if (isset($_POST['dest'])) $dest = $_POST['dest'];
if ($title and $text) {
$url = "https://api.pushbullet.com/v2/pushes";
$data = '{' . ($dest ? '"device_iden": "' . $dest . '", ' : '') . '"type": "note", "title": "' . $title . '", "body": "' . $text . '"}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer [ACCESS TOKEN]",
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);
exit;
}
header("HTTP/1.0 404 Not Found");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment