send push notifications from your website to your mobile, desktop devices, php script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    script send push notifications from your website to your mobile, desktop devices, php script

    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($cCURLOPT_HTTPHEADER, array(
                
    'Access-Token: '.$access_token,
                
    'Content-Type: application/json',
                
    'Content-Length: ' strlen($json_data)
            ));
            
    // set url
            
    curl_setopt($cCURLOPT_URL$url);
            
    curl_setopt($cCURLOPT_POST1);
            
    curl_setopt($cCURLOPT_POSTFIELDS$json_data);
            
    //return the transfer as a string
            
    curl_setopt($cCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($cCURLOPT_FOLLOWLOCATIONtrue);
            
    // $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;
    }

    ?>
    Advertise your mobile site for FREE with AdTwirl

Working...
X