function admin(&$out)
 {
     /*if ($this->mode == 'update') {
     			global $API_Key;
                 setGlobal('PushBullet.API_KEY',$API_Key);
     			$out['API_KEY'] = getGlobal('PushBullet.API_KEY');
     		}*/
     if ($this->mode == 'import' || $this->mode == 'update') {
         global $API_Key;
         if ($API_Key != "") {
             $table_name = 'app_pushbullet';
             $p = new PushBullet($API_Key);
             $devices = $p->getDevices();
             $rec_ok = 1;
             $i = 0;
             while ($rec_ok) {
                 $rec = array();
                 $rec['apikey'] = $API_Key;
                 $rec['iden'] = $devices['devices'][$i]['iden'];
                 $rec['name'] = $devices['devices'][$i]['nickname'];
                 if ($rec['iden'] == '') {
                     $rec_ok = 0;
                 }
                 if ($rec_ok) {
                     $old = SQLSelectOne("SELECT ID FROM " . $table_name . " WHERE iden LIKE '" . DBSafe($rec['iden']) . "'");
                     if ($old['ID']) {
                         //$rec['ID'] = $old['ID'];
                         //SQLUpdate($table_name, $rec);
                     } else {
                         SQLInsert($table_name, $rec);
                     }
                     $out["TOTAL"]++;
                 }
                 $i++;
             }
             $out['OK'] = 1;
         } else {
             //$out['ERR'] = 1;
         }
     }
     if ($this->view_mode == '' || $this->view_mode == 'view_devices') {
         $this->view_devices($out);
     }
     if ($this->view_mode == 'edit_devices') {
         $this->edit_devices($out, $this->id);
     }
     if ($this->view_mode == 'delete_devices') {
         $this->delete_devices($this->id);
         $this->redirect("?");
     }
 }
Ejemplo n.º 2
0
// See classes/ImapMailbox.php for some examples
define('MAIL_EMAIL', '*****@*****.**');
// Your e-mail username
define('MAIL_PASSWORD', 'password');
// Your e-mail password
// PushBullet settings
$PushBullet_API_key = 'pushbullet_api_key_goes_here';
$deviceIds = array('device_id_1', 'device_id_2', 'device_id_3');
// Start readin the mailbox
$mailbox = new ImapMailbox(MAIL_PATH, MAIL_EMAIL, MAIL_PASSWORD, false, 'utf-8');
// Get all e-mails from the mailbox
$mailsIds = $mailbox->searchMailBox('ALL');
if ($mailsIds) {
    // Read each mail individually
    foreach ($mailsIds as $mailId) {
        $mail = $mailbox->getMail($mailId);
        // Send the PushBullet notifications
        try {
            $p = new PushBullet($PushBullet_API_key);
            // Send a notification to each device
            foreach ($deviceIds as $deviceId) {
                $p->pushNote($deviceId, $mail->subject, $mail->textPlain);
            }
            // Delete the mail from the folder
            $mailbox->deleteMail($mailId);
        } catch (PushBulletException $e) {
            // Die() on error
            die($e->getMessage());
        }
    }
}
<?php

require 'PushBullet.class.php';
try {
    #### AUTHENTICATION ####
    // Get your API key here: https://www.pushbullet.com/account
    $p = new PushBullet('YOUR_API_KEY');
    #### Get methods
    // Print the definitions for your own devices. Useful for getting the 'iden' for using with the push methods.
    print_r($p->getDevices());
    // Print the definitions for contacts/devices shared with you. Useful for getting 'iden', too.
    print_r($p->getContacts());
    // Print information about your Pushbullet account
    print_r($p->getUserInformation());
    // Print a list of sent push notifications, modified after 1400441645 unix time
    print_r($p->getPushHistory(1400441645));
    #### Push methods
    // Push to email me@example.com a note with a title 'Hey!' and a body 'It works!'
    $p->pushNote('*****@*****.**', 'Hey!', 'It works!');
    // Push to device s2GBpJqaq9IY5nx a note with a title 'Hey!' and a body 'It works!'
    $p->pushNote('s2GBpJqaq9IY5nx', 'Hey!', 'It works!');
    // Push to device gXVZDd2hLY6TOB1 a link with a title 'ivkos at GitHub', a URL 'https://github.com/ivkos' and body 'Pretty useful.'
    $p->pushLink('gXVZDd2hLY6TOB1', 'ivkos at GitHub', 'https://github.com/ivkos', 'Pretty useful.');
    // Push to device a91kkT2jIICD4JH a Google Maps address with a name 'Google HQ' and an address '1600 Amphitheatre Parkway'
    $p->pushAddress('a91kkT2jIICD4JH', 'Google HQ', '1600 Amphitheatre Parkway');
    // Push to device qVNRhnXxZzJ95zz a to-do list with a title 'Shopping List' and items 'Milk' and 'Butter'
    $p->pushList('qVNRhnXxZzJ95zz', 'Shopping List', array('Milk', 'Butter'));
    // Push to device 0PpyWzARDK0w6et the file '../pic.jpg' of MIME type image/jpeg
    // Method accepts absolute and relative paths.
    $p->pushFile('0PpyWzARDK0w6et', '../pic.jpg', 'image/jpeg');
    // If the MIME type argument is omitted, an attempt to guess it will be made.
Ejemplo n.º 4
0
/**
* Title
*
* Description
*
* @access public
*/
function postToPushbullet($ph)
{
    $push_bullet_apikey = trim(SETTINGS_PUSHBULLET_KEY);
    $p = new PushBullet($push_bullet_apikey);
    if (mb_strlen($title, 'UTF-8') > 100) {
        $title = mb_substr($title, 0, 100, 'UTF-8') . '...';
        $data = $ph;
    } else {
        $title = $ph;
        $data = '';
    }
    if (defined('SETTINGS_PUSHBULLET_DEVICE_ID')) {
        $devices = explode(',', SETTINGS_PUSHBULLET_DEVICE_ID);
        $total = count($devices);
        for ($i = 0; $i < $total; $i++) {
            $push_bullet_device_id = trim($devices[$i]);
            if ($push_bullet_device_id) {
                try {
                    $res = $p->pushNote($push_bullet_device_id, $title, $data);
                } catch (Exception $e) {
                    registerError('pushbullet', get_class($e) . ', ' . $e->getMessage());
                }
            }
        }
    } else {
        $res = $p->getDevices();
        $devices = $res->devices;
        $total = count($devices);
        for ($i = 0; $i < $total; $i++) {
            if ($devices[$i]->iden) {
                try {
                    $res = $p->pushNote($devices[$i]->iden, $title, $data);
                } catch (Exception $e) {
                    registerError('pushbullet', get_class($e) . ', ' . $e->getMessage());
                }
            }
        }
    }
}
Ejemplo n.º 5
0
<?php

echo "the button received\n";
$msg = "\nThe red button was pushed.\n";
require 'PushBullet.class.php';
//https://github.com/PENDOnl/emails-to-pushbullet/blob/master/classes/pushbullet.class.php
$p = new PushBullet('yourOauthToken');
$p->pushNote('yourDeviceToen', 'RED Button', $msg);
mail("*****@*****.**", "RED Button", $msg, "From: golem@yourserver.com\r\n");
?>