Pushbullet provides a service where you can send push messages to your mobile, desktop devices, they also provide an API for their service, with the api you can send notifications from your website about new user signup, payment or new shoppingcard order directly to your devices as a push message. The code below shows a PHP example how to send a "Hello World" message to your devices with a Pushbullet service. Change the "Hello World!" text to any other text you want to send.
PHP Code:
<?php
//php code by gumslone http://coding-talk.com/
$output = pushbullet_push('Hello World!');
print_r(json_decode($output,true));
function pushbullet_push($text)
{
if(!empty($text))
{
$access_token = 'paste_it_here'; //get it from your account settings https://www.pushbullet.com/#settings/account
$url = 'https://api.pushbullet.com/v2/pushes';
$json_data = json_encode(array('body'=>$text, 'type'=>'note'));
// create curl resource
$c = curl_init();
// set headers
curl_setopt($c, CURLOPT_HTTPHEADER, array(
'Access-Token: '.$access_token,
'Content-Type: application/json',
'Content-Length: ' . strlen($json_data)
));
// set url
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $json_data);
//return the transfer as a string
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
// $output contains the output string
$output = curl_exec($c);
// close curl resource to free up system resources
curl_close($c);
}
else
{
$output = '{"error":"no text to push"}';
}
return $output;
}
?>