示例#1
0
 public function actionTest()
 {
     /*      $user_id = Yii::app()->user->id;
           var_dump(Yii::app()->user->isAdmin);
           //print_r(User::model()->findByPk($user_id));
           echo 'Places='.Place::model()->countUserPlaces($user_id);
           echo 'Blocks='.Place::model()->countOwnedBlocks($user_id);
           echo 'Estabs='.Place::model()->countOwnedEstablishments($user_id);
           yexit();*/
     $po = new Pushover();
     $po->setToken(Yii::app()->params['pushover']['key']);
     $po->setUser(getUserProfile(Yii::app()->user->id)->getAttribute('pushover_token'));
     $po->setDevice(getUserProfile(Yii::app()->user->id)->getAttribute('pushover_device'));
     $po->setTitle('Hey ' . getFirstName());
     $po->setMessage('Hello world! ' . time());
     $po->setUrl('http://jeffreifman.com/blog/');
     $po->setUrlTitle('cool blog');
     $po->setPriority(1);
     $po->setTimestamp(time());
     $po->setDebug(true);
     $go = $po->send();
     echo '<pre>';
     print_r($go);
     echo '</pre>';
 }
 private static function pushNotification($userKey, $message, $title = null, $url = null, $urltitle = null)
 {
     Notifications::addLog('Pushover[pushNotification' . ']; $userKey=[' . $userKey . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING');
     $notification = new Pushover();
     $token = Config::get('applicationToken', 'msg_pushover');
     if (is_null($token)) {
         throw new Exception("Pushover - Application token not specified", 500);
     }
     if (is_null($userKey)) {
         throw new Exception("Pushover - User key not specified", 500);
     }
     $notification->setToken($token);
     $notification->setUser($userKey);
     $notification->setMessage($message);
     if (!is_null($title)) {
         $notification->setTitle($title);
     }
     $notification->setHtml(1);
     $notification->setUrl($url);
     $notification->setUrlTitle($urltitle);
     if (!$notification->send()) {
         Notifications::addError("Pushover - Error in sending a notification to '{$userKey}'");
     } else {
         Notifications::addSuccess('Pushover message sent.');
     }
 }
示例#3
0
 /**
  * send push notifications. Currently only pushover.net is supported
  *
  */
 public static function send($subject, $url)
 {
     $app_key = \OCP\Config::getSystemValue('pushnotifications_pushover_app', '');
     $pushid = trim(\OCP\Config::getUserValue(\OCP\User::getUser(), 'pushnotifications', 'pushid', ''));
     if (!empty($pushid)) {
         $push = new \Pushover();
         $push->setToken($app_key);
         $push->setUser($pushid);
         $push->setMessage($subject);
         $push->setUrl($url);
         $push->setUrlTitle('ownCloud');
         $push->setCallback($url);
         $push->setTimestamp(time());
         $push->setDebug(true);
         $go = $push->send();
         unset($push);
     }
 }
示例#4
0
/**
 * Prepare a new Pushover util.
 *
 * @return \Pushover
 */
function psm_build_pushover()
{
    $pushover = new \Pushover();
    $pushover->setToken(psm_get_conf('pushover_api_token'));
    return $pushover;
}
示例#5
0
<?php

/**
 * @author Chris Schalenborgh <*****@*****.**>
 * @version 0.1
 */
include 'Pushover.php';
$push = new Pushover();
$push->setToken('app token goes here');
$push->setUser('user token goes here');
$push->setTitle('Hey Chris');
$push->setMessage('Hello world! ' . time());
$push->setUrl('http://chris.schalenborgh.be/blog/');
$push->setUrlTitle('cool php blog');
$push->setDevice('iPhone');
$push->setPriority(2);
$push->setRetry(60);
//Used with Priority = 2; Pushover will resend the notification every 60 seconds until the user accepts.
$push->setExpire(3600);
//Used with Priority = 2; Pushover will resend the notification every 60 seconds for 3600 seconds. After that point, it stops sending notifications.
$push->setCallback('http://chris.schalenborgh.be/');
$push->setTimestamp(time());
$push->setDebug(true);
$push->setSound('bike');
$go = $push->send();
echo '<pre>';
print_r($go);
echo '</pre>';