• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Model\notification函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中JPush\Model\notification函数的典型用法代码示例。如果您正苦于以下问题:PHP notification函数的具体用法?PHP notification怎么用?PHP notification使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了notification函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: sendByAlias

 /**
  * android别名发送
  * @param $title string 消息内容
  * @param $alias array 别名数组
  */
 public function sendByAlias($title, $alias)
 {
     $this->setPlatform = M\platform('android');
     $this->setAudience = M\alias($alias);
     $this->setNotification = M\notification($title);
     return $this->send();
 }
开发者ID:nuke2015,项目名称:jpush,代码行数:12,代码来源:Android.class.php


示例2: push

 public function push()
 {
     $app_key = $this->settings['jpushkey'];
     $master_secret = $this->settings['jpushsecret'];
     //'46867b6b0c46b34ee6848b56';
     $client = new JPushClient($app_key, $master_secret);
     $device_token = $this->input['device_token'];
     if (!$device_token) {
         $this->errorOutput('NO_DEVICE_TOKEN');
     }
     $message = $this->input['message'];
     if (!$message) {
         $this->errorOutput('NO_MESSAGE');
     }
     $module = $this->input['module'];
     $content_id = $this->input['content_id'];
     if ($module) {
         $options = array($module => $content_id);
     } else {
         $options = array();
     }
     $result = $client->push()->setPlatform(M\Platform('android'))->setAudience(M\audience(M\alias(array($device_token))))->setNotification(M\notification($message, M\android($message, '', 1, $options)))->send();
     $this->addItem_withkey('result', $result->isOk ? 1 : 0);
     $this->output();
 }
开发者ID:h3len,项目名称:Project,代码行数:25,代码来源:jpush.php


示例3: handle

 /**
  * Execute the job.
  *
  * @param JPushClient $client
  */
 public function handle(JPushClient $client)
 {
     $error = '';
     try {
         if ($this->download($this->url)) {
             $package = Package::createFromFile($this->tmpFile, basename($this->url), $this->user->id);
             $result = Push::send($this->devices, $package, $this->user->id);
             try {
                 if ($this->devices->count() > 1) {
                     $msg = "已在向{$this->devices->count()}台设备发出推送...";
                 } else {
                     $msg = "已向{$this->devices->first()->alias}发出推送...";
                 }
                 Log::info($msg);
             } catch (\Exception $e) {
                 Log::error('[PushApk Job]推送失败' . $e->getMessage());
                 return;
             }
         } else {
             $error = trans('errors.download_failed');
             Log::error('[PushApk Job]下载文件失败: ' . $this->url);
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
         Log::error('[PushApk]' . $e->getMessage() . '  ' . $this->url);
     }
     $installIds = $this->devices->pluck('install_id')->toArray();
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\registration_id($installIds))->setNotification(M\notification('出现错误,请检查URL是否正确'))->send();
     } catch (Exception $ignored) {
     }
 }
开发者ID:imjerrybao,项目名称:PushApp,代码行数:37,代码来源:PushApk.php


示例4: pushMessage

 /**
  * 推送消息到app
  * @param $content
  * @param $title
  * @param $extras
  */
 private function pushMessage($content, $title, $extras)
 {
     $pushConf = C('push');
     $br = '<br/>';
     $app_key = $pushConf['app_key'];
     $master_secret = $pushConf['master_secret'];
     $client = new JPushClient($app_key, $master_secret);
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification(M\android($content, $title, 3, $extras)))->send();
         echo 'Push Success.' . $br;
         echo 'sendno : ' . $result->sendno . $br;
         echo 'msg_id : ' . $result->msg_id . $br;
         echo 'Response JSON : ' . $result->json . $br;
     } catch (APIRequestException $e) {
         echo 'Push Fail.' . $br;
         echo 'Http Code : ' . $e->httpCode . $br;
         echo 'code : ' . $e->code . $br;
         echo 'message : ' . $e->message . $br;
         echo 'Response JSON : ' . $e->json . $br;
         echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
         echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
         echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
     } catch (APIConnectionException $e) {
         echo 'Push Fail.' . $br;
         echo 'message' . $e->getMessage() . $br;
     }
 }
开发者ID:Maplecms,项目名称:shopnc-api,代码行数:33,代码来源:article.php


示例5: send

 function send($content)
 {
     $br = '<br/>';
     $client = new JPushClient($this->_app_key, $this->_master_secret);
     $result = $client->push()->setPlatform(JPushModel\all)->setAudience(JPushModel\all)->setNotification(JPushModel\notification($content))->send();
     return $result;
 }
开发者ID:jin123456bat,项目名称:home,代码行数:7,代码来源:jpush.php


示例6: easy

 /**
 * 全平台简易发送
     测试用例:list($status,$data)=$Notification->easy('hello feng!');
 */
 public function easy($title)
 {
     $this->setPlatform = M\all;
     $this->setAudience = M\all;
     $this->setNotification = M\notification($title);
     return $this->send();
 }
开发者ID:nuke2015,项目名称:jpush,代码行数:11,代码来源:Notification.class.php


示例7: push_by_tag

 /**
  * [push 根据标签推送]
  * @param  [type] $tag 		[标签]
  * @param  [type] $msg 		[信息数组]
  * @return [type]           [description]
  */
 public function push_by_tag($tag, $msg)
 {
     try {
         $client = new JPushClient($this->app_key, $this->master_secret);
         $result = $client->push()->setPlatform(M\all)->setAudience(M\audience(M\tag($tag)))->setNotification(M\notification($msg))->send();
     } catch (APIRequestException $e) {
     } catch (APIConnectionException $e) {
     }
 }
开发者ID:897475686,项目名称:bbm,代码行数:15,代码来源:push_service.php


示例8: pushMessageByTags

 /**
  *
  * 根据Tag推送消息
  * @param $content
  * @param $title
  * @param $extras
  * @param $tags
  */
 public function pushMessageByTags($content, $title, $extras, $tags)
 {
     $client = new JPushClient($this->app_key, $this->master_secret);
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\audience(M\tag($tags)))->setNotification(M\notification(M\android($content, $title, 3, $extras)))->send();
     } catch (APIRequestException $e) {
     } catch (APIConnectionException $e) {
     }
 }
开发者ID:Maplecms,项目名称:shopnc-api,代码行数:17,代码来源:jpush.php


示例9: push_message_registration

 /**
  * 推送 push_message
  */
 public function push_message_registration($ids = array(), $notification = array())
 {
     if ($ids && $notification) {
         vendor('jpush.autoload');
         $app_key = C('API_PUSH_JPUSH.key');
         $master_secret = C('API_PUSH_JPUSH.secret');
         $client = new JPushClient($app_key, $master_secret);
         $client->push()->setPlatform(M\all)->setAudience(M\registration_id($ids))->setNotification(M\notification($notification['title'], M\android($notification['title'], $notification['title'], NULL, $notification['extras']), M\ios($notification['title'], 'default', 1)))->setOptions(M\options(NULL, NULL, NULL, true))->send();
     }
 }
开发者ID:liqihua,项目名称:yanzhihui,代码行数:13,代码来源:PushController.class.php


示例10: pushAll

 function pushAll($msg, $title = null, $arr = null)
 {
     try {
         $jpushClient = $this->client;
         $result = $jpushClient->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification(M\android($msg, $title, null, $arr), M\ios($msg, 'default', '+1', true, $arr)))->send();
         return array('status' => true, 'msg' => '发送成功!');
     } catch (APIConnectionException $e) {
         return array('status' => false, 'msg' => '推送失败!');
     } catch (APIRequestException $e) {
         return array('status' => false, 'msg' => $e->getMessage());
     } catch (InvalidArgumentException $e) {
         return array('status' => false, 'msg' => '推送失败!');
     }
 }
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:14,代码来源:MyJpush.class.php


示例11: pushMessage

 public static function pushMessage($uids, $alert, array $extras = null)
 {
     $config = self::getConfig();
     $app_key = $config['app_key'];
     $master_secret = $config['master_secret'];
     if (!$app_key || !$master_secret) {
         return;
     }
     $client = new JPushClient($app_key, $master_secret);
     try {
         $uids = array_values(array_map('strval', $uids));
         $audience = M\audience(M\alias($uids));
         $notification = M\notification($alert, M\android($alert, null, null, $extras), M\ios($alert, null, null, null, $extras));
         $result = $client->push()->setPlatform(M\all)->setAudience($audience)->setNotification($notification)->send();
         //echo 'Push Success.' . PHP_EOL;
         //echo 'sendno : ' . $result->sendno . PHP_EOL;
         //echo 'msg_id : ' .$result->msg_id . PHP_EOL;
         //echo 'Response JSON : ' . $result->json . PHP_EOL;
     } catch (\Exception $e) {
         echo 'Push Fail: ' . $e->getMessage() . PHP_EOL;
     }
 }
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:22,代码来源:Jpush.php


示例12: easy_push

 public function easy_push($id, $content = 'hello')
 {
     $br = '<br/>';
     $spilt = ' - ';
     $master_secret = '3dd1c77ac980516110338aa5';
     $app_key = 'ab36dbc34e0501604d25974e';
     JPushLog::setLogHandlers(array(new StreamHandler('jpush.log', Logger::DEBUG)));
     $client = new JPushClient($app_key, $master_secret);
     $json = array('type' => 2);
     //echo $json;
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\alias(array($id)))->setNotification(M\notification($content, M\android('hi,android', $title = null, $builder_id = null, $extras = $json)))->printJSON()->send();
         /*$result = $client->push()
           ->setPlatform(M\all)
           ->setAudience(M\alias(array($id)))
           ->setNotification(M\notification($content))
           ->printJSON()
           ->send();*/
         echo 'Push Success.' . $br;
         echo 'sendno : ' . $result->sendno . $br;
         echo 'msg_id : ' . $result->msg_id . $br;
         echo 'Response JSON : ' . $result->json . $br;
     } catch (APIRequestException $e) {
         echo 'Push Fail.' . $br;
         echo 'Http Code : ' . $e->httpCode . $br;
         echo 'code : ' . $e->code . $br;
         echo 'Error Message : ' . $e->message . $br;
         echo 'Response JSON : ' . $e->json . $br;
         echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
         echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
         echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
     } catch (APIConnectionException $e) {
         echo 'Push Fail: ' . $br;
         echo 'Error Message: ' . $e->getMessage() . $br;
         //response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again.
         echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br;
     }
 }
开发者ID:xzjs,项目名称:PXPark,代码行数:38,代码来源:PushController.class.php


示例13: pushNotificationAll

 public function pushNotificationAll($msg, $title = null, $extras = null)
 {
     $result = $this->client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification($msg, M\android($msg, $title, null, $extras), M\ios($msg, null, null, null, $extras), M\winphone($msg, $title, null, $extras)))->send();
     return $result->isOk;
 }
开发者ID:Emon0526,项目名称:zhuoying-wx,代码行数:5,代码来源:JPushLogic.class.php


示例14: index

 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * http://example.com/index.php/welcome
  * - or -
  * http://example.com/index.php/welcome/index
  * - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  *
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $br = '<br/>';
     $spilt = ' - ';
     $master_secret = '3047c84ce72ed9ab392e6be1';
     $app_key = '57d93d27208ab6e2516b129d';
     JPushLog::setLogHandlers(array(new StreamHandler('jpush.log', Logger::DEBUG)));
     $client = new JPushClient($app_key, $master_secret);
     // easy push
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification('Hi, JPush'))->printJSON()->send();
         echo 'Push Success.' . $br;
         echo 'sendno : ' . $result->sendno . $br;
         echo 'msg_id : ' . $result->msg_id . $br;
         echo 'Response JSON : ' . $result->json . $br;
     } catch (APIRequestException $e) {
         echo 'Push Fail.' . $br;
         echo 'Http Code : ' . $e->httpCode . $br;
         echo 'code : ' . $e->code . $br;
         echo 'Error Message : ' . $e->message . $br;
         echo 'Response JSON : ' . $e->json . $br;
         echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
         echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
         echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
     } catch (APIConnectionException $e) {
         echo 'Push Fail: ' . $br;
         echo 'Error Message: ' . $e->getMessage() . $br;
         // response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again.
         echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br;
     }
     echo $br . '-------------' . $br;
     // easy push with ios badge +1
     // 以下演示推送给 Android, IOS 平台下Tag为tag1的用户的示例
     try {
         $result = $client->push()->setPlatform(M\Platform('android', 'ios'))->setAudience(M\Audience(M\Tag(array('tag1'))))->setNotification(M\notification('Hi, JPush', M\android('Hi, Android', 'Message Title', 1, array("key1" => "value1", "key2" => "value2")), M\ios("Hi, IOS", "happy", "+1", true, array("key1" => "value1", "key2" => "value2"), "Ios8 Category")))->setMessage(M\message('Message Content', 'Message Title', 'Message Type', array("key1" => "value1", "key2" => "value2")))->printJSON()->send();
         echo 'Push Success.' . $br;
         echo 'sendno : ' . $result->sendno . $br;
         echo 'msg_id : ' . $result->msg_id . $br;
         echo 'Response JSON : ' . $result->json . $br;
     } catch (APIRequestException $e) {
         echo 'Push Fail.' . $br;
         echo 'Http Code : ' . $e->httpCode . $br;
         echo 'code : ' . $e->code . $br;
         echo 'Error Message : ' . $e->message . $br;
         echo 'Response JSON : ' . $e->json . $br;
         echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
         echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
         echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
     } catch (APIConnectionException $e) {
         echo 'Push Fail: ' . $br;
         echo 'Error Message: ' . $e->getMessage() . $br;
         // response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again.
         echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br;
     }
     echo $br . '-------------' . $br;
     // full push
     try {
         $result = $client->push()->setPlatform(M\platform('ios', 'android'))->setAudience(M\audience(M\tag(array('555', '666')), M\alias(array('555', '666'))))->setNotification(M\notification('Hi, JPush', M\android('Hi, android'), M\ios('Hi, ios', 'happy', 1, true, null, 'THE-CATEGORY')))->setMessage(M\message('msg content', null, null, array('key' => 'value')))->setOptions(M\options(123456, null, null, false, 0))->printJSON()->send();
         echo 'Push Success.' . $br;
         echo 'sendno : ' . $result->sendno . $br;
         echo 'msg_id : ' . $result->msg_id . $br;
         echo 'Response JSON : ' . $result->json . $br;
     } catch (APIRequestException $e) {
         echo 'Push Fail.' . $br;
         echo 'Http Code : ' . $e->httpCode . $br;
         echo 'code : ' . $e->code . $br;
         echo 'message : ' . $e->message . $br;
         echo 'Response JSON : ' . $e->json . $br;
         echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
         echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
         echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
     } catch (APIConnectionException $e) {
         echo 'Push Fail: ' . $br;
         echo 'Error Message: ' . $e->getMessage() . $br;
         // response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again.
         echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br;
     }
     echo $br . '-------------' . $br;
     // fail push
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification('Hi, JPush'))->setAudience(M\audience(array('no one')))->printJSON()->send();
         echo 'Push Success.' . $br;
         echo 'sendno : ' . $result->sendno . $br;
         echo 'msg_id : ' . $result->msg_id . $br;
//.........这里部分代码省略.........
开发者ID:subo-romens,项目名称:phpsunbo,代码行数:101,代码来源:IosPush.php


示例15: isset

use JPush\Model as M;
$fromCellPhone = isset($_REQUEST['cellPhone']) ? $_REQUEST['cellPhone'] : "";
$nickname = isset($_REQUEST['nickname']) ? $_REQUEST['nickname'] : "匿名";
$targetCellPhone = isset($_REQUEST['targetCellPhone']) ? $_REQUEST['targetCellPhone'] : "";
$message = isset($_REQUEST['message']) ? $_REQUEST['message'] : "召唤";
if (empty($targetCellPhone) or empty($fromCellPhone)) {
    die("nothing else comes so close");
}
$target = $prefix . $targetCellPhone;
$br = '<br/>';
$spilt = ' - ';
//JPushLog::setLogHandlers(array(new StreamHandler('jpush.log', Logger::DEBUG)));
$client = new JPushClient($app_key, $master_secret);
// 以下演示推送给 Android, IOS 平台下Tag为tag1的用户的示例
try {
    $result = $client->push()->setPlatform(M\Platform('ios'))->setAudience(M\Audience(M\alias([$target])))->setNotification(M\notification('来自' . $nickname . '的指令:' . $message, M\ios('来自' . $nickname . '的指令:' . $message, "happy", "+1", true, ["from" => $nickname, "message" => $message], "BearRemoter")))->printJSON()->send();
    echo 'Push Success.' . $br;
    echo 'sendno : ' . $result->sendno . $br;
    echo 'msg_id : ' . $result->msg_id . $br;
    echo 'Response JSON : ' . $result->json . $br;
} catch (APIRequestException $e) {
    echo 'Push Fail.' . $br;
    echo 'Http Code : ' . $e->httpCode . $br;
    echo 'code : ' . $e->code . $br;
    echo 'Error Message : ' . $e->message . $br;
    echo 'Response JSON : ' . $e->json . $br;
    echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
    echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
    echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
} catch (APIConnectionException $e) {
    echo 'Push Fail: ' . $br;
开发者ID:vimac,项目名称:BearRemoter-Server,代码行数:31,代码来源:send.php


示例16: pushNotificationAlliOS

 public function pushNotificationAlliOS($msg, $title = null, $extras = null)
 {
     $result = $this->client->push()->setPlatform(M\platform('ios'))->setAudience(M\all)->setNotification(M\notification($msg, M\android($msg, $title, null, $extras), M\ios($msg, 'happy', 0, null, $extras), M\winphone($msg, $title, null, $extras)))->setOptions(M\options(null, null, null, true, null))->send();
     $this->writeLog($result);
     return $result->isOk;
 }
开发者ID:Emon0526,项目名称:zhuoying-wx,代码行数:6,代码来源:JPushLogic.class.php


示例17: catch

    echo 'code : ' . $e->code . $br;
    echo 'message : ' . $e->message . $br;
    echo 'Response JSON : ' . $e->json . $br;
    echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
    echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
    echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
} catch (APIConnectionException $e) {
    echo 'Push Fail: ' . $br;
    echo 'Error Message: ' . $e->getMessage() . $br;
    //response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again.
    echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br;
}
echo $br . '-------------' . $br;
//fail push
try {
    $result = $client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification('Hi, JPush'))->setAudience(M\audience(array('no one')))->printJSON()->send();
    echo 'Push Success.' . $br;
    echo 'sendno : ' . $result->sendno . $br;
    echo 'msg_id : ' . $result->msg_id . $br;
    echo 'Response JSON : ' . $result->json . $br;
} catch (APIRequestException $e) {
    echo 'Push Fail.' . $br;
    echo 'Http Code : ' . $e->httpCode . $br;
    echo 'code : ' . $e->code . $br;
    echo 'message : ' . $e->message . $br;
    echo 'Response JSON : ' . $e->json . $br;
    echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
    echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
    echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
} catch (APIConnectionException $e) {
    echo 'Push Fail: ' . $br;
开发者ID:OranTing,项目名称:gdby_github_repo,代码行数:31,代码来源:PushExample.php


示例18: StreamHandler

use JPush\Model as M;
use JPush\JPushClient;
use JPush\JPushLog;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use JPush\Exception\APIConnectionException;
use JPush\Exception\APIRequestException;
$br = '<br/>';
$spilt = ' - ';
$master_secret = 'd94f733358cca97b18b2cb98';
$app_key = '47a3ddda34b2602fa9e17c01';
JPushLog::setLogHandlers(array(new StreamHandler('jpush.log', Logger::DEBUG)));
$client = new JPushClient($app_key, $master_secret);
//easy push
try {
    $result = $client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification('Hi, JPush', M\ios("Hi, IOS", "happy", "+1")))->printJSON()->send();
    echo 'Push Success.' . $br;
    echo 'sendno : ' . $result->sendno . $br;
    echo 'msg_id : ' . $result->msg_id . $br;
    echo 'Response JSON : ' . $result->json . $br;
} catch (APIRequestException $e) {
    echo 'Push Fail.' . $br;
    echo 'Http Code : ' . $e->httpCode . $br;
    echo 'code : ' . $e->code . $br;
    echo 'Error Message : ' . $e->message . $br;
    echo 'Response JSON : ' . $e->json . $br;
    echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
    echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
    echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
} catch (APIConnectionException $e) {
    echo 'Push Fail: ' . $br;
开发者ID:OranTing,项目名称:gdby_github_repo,代码行数:31,代码来源:PushExample2.php


示例19: markPolice

 /**
  * 标记发现交警的地点, 并向附近用户推送提示信息
  * @method markPolice
  * @return [type]
  *
  * @author wesley zhang <[email protected]>
  * @since  2015-08-11T16:30:19+0800
  */
 function markPolice()
 {
     global $db;
     $userid = $_REQUEST['userid'];
     $long = $_REQUEST['long'];
     $lat = $_REQUEST['lat'];
     $imgurl = $_REQUEST['imgurl'];
     $content = $_REQUEST['content'];
     $address = $_REQUEST['address'];
     if (!$userid) {
         $this->res['error'] = 1;
         $this->res['msg'] = '用户id不存在';
         return $this->res;
     }
     $aNewRec = array('user_id' => $userid, 'longitude' => $long, 'latitude' => $lat, 'image_url' => $imgurl, 'content' => $content, 'address' => $address, 'created_date' => $db->now());
     $id = $db->insert('mark_trafficpolice', $aNewRec);
     //获得附近停车用户
     $aUsers = $this->_getNearbyUsers($long, $lat);
     $sPushMsg = '您当前' . $this->searchRadius . '千米的范围内有交警,请注意!';
     if (count($aUsers)) {
         $sMsgType = 'markPolice';
         //去除重复用户
         $aPushAlias = array();
         $aPushUsersInfo = array();
         foreach ($aUsers as $user) {
             if (!in_array($user['user_name'], $aPushAlias) && $userid != $user['user_id']) {
                 $aPushAlias[] = $user['user_name'];
                 $aPushUsersInfo[] = $user;
             }
         }
         // 使用jpush 推送消息,
         // Options: 第一个参数为sendno,纯粹用来作为 API 调用标识,API 返回时被原样返回,以方便 API 调用方匹配请求与返回。
         //Options: 第二个参数为time_to_live,0 表示不保留离线消息,只有推送当前在线的用户可以收到。默认 86400 (1 天),最长 10 天
         // Options: http://docs.jpush.io/server/rest_api_v3_push/#options
         try {
             $client = new JPushClient($this->appKey, $this->masterSecret);
             $response = $client->push()->setPlatform(M\all)->setAudience(M\audience(M\alias($aPushAlias)))->setNotification(M\notification($sPushMsg))->setOptions(M\options($id, 0, null, true))->send();
             // $aPusRes = $this->_objectToArray($response);
             // if($response->isOk == 1){
             //      //推送成功, 标记用户收到推送
             // }
         } catch (Exception $e) {
             // print('<pre>');
             // print_r($e->getMessage());
             // print('</pre>');
         }
         //不管推送是否成功, 都标记用户收到
         foreach ($aPushUsersInfo as $user) {
             $aNewLog = array('mt_id' => $id, 'user_id' => $user['user_id'], 'push_content' => $sPushMsg, 'push_param' => $response->json, 'created_date' => $db->now());
             $db->insert('mark_trafficpolice_received', $aNewLog);
         }
     }
     $aRes = array('id' => $id);
     if ($id) {
         $this->res['data'] = $aRes;
         $this->res['error'] = 0;
         $this->res['msg'] = '保存成功';
     } else {
         $this->res['error'] = 1;
         $this->res['msg'] = '保存失败';
     }
     return $this->res;
 }
开发者ID:szgongyi,项目名称:TrafficPolice-Web,代码行数:71,代码来源:cls_api.php


示例20: switch

if (isset($uid) && isset($msg) && isset($role)) {
    $rs_arr = $d2b->select("user_main", ["channelid"], ["uid" => $uid]);
    $channelid = $rs_arr[0]['channelid'];
    switch ($role) {
        case 1:
            $client = new JPushClient($app_key_c, $master_secret_c);
            try {
                $result = $client->push()->setPlatform(M\platform('ios', 'android'))->setAudience(M\audience(M\registration_id(array($channelid))))->setNotification(M\notification($msg, M\android($msg), M\ios($msg, 'happy', 1, true, null, 'THE-CATEGORY')))->setMessage(M\message($msg, null, null, array('key' => 'value')))->setOptions(M\options(123456, null, null, false, 0))->send();
                $return_arr = ["channelid" => $channelid];
                include "../include/return_data.php";
            } catch (APIRequestException $e) {
                echo 'code : ' . $e->code;
            }
            break;
        case 2:
            $client = new JPushClient($app_key_p, $master_secret_p);
            try {
                $result = $client->push()->setPlatform(M\platform('ios', 'android'))->setAudience(M\audience(M\registration_id(array($channelid))))->setNotification(M\notification($msg, M\android($msg), M\ios($msg, 'happy', 1, true, null, 'THE-CATEGORY')))->setMessage(M\message($msg, null, null, array('key' => 'value')))->setOptions(M\options(123456, null, null, false, 0))->send();
                $return_arr = ["channelid" => $channelid];
                include "../include/return_data.php";
            } catch (APIRequestException $e) {
                echo 'code : ' . $e->code;
            }
            break;
        default:
            echo json_encode(0);
            break;
    }
} else {
    echo json_encode(0);
}
开发者ID:carriercomm,项目名称:MyHome,代码行数:31,代码来源:push_test.php



注:本文中的JPush\Model\notification函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP JShrink\Minifier类代码示例发布时间:2022-05-23
下一篇:
PHP Utilities\ArrayHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap