Created
July 25, 2015 07:22
-
-
Save gyengus/1e1cb2a697dab07ab9bb to your computer and use it in GitHub Desktop.
Pushbullet gateway
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 | |
$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