コード例 #1
0
ファイル: BaiduPushService.php プロジェクト: onlineshine/myzf
 public function SendBatchUniMsg(array $channlIds, $title = null, $content, array &$err = array())
 {
     //andriod push start
     $sendAndInfo = array('title' => $title, 'description' => $content, "custom_content" => $this->getInfo());
     $ars = $this->pushSdkAnd->pushBatchUniMsg($channlIds, $sendAndInfo, $this->opts);
     //        if($ars === false) {
     $err['and']['code'] = $this->pushSdkAnd->getLastErrorCode();
     $err['and']['msg'] = $this->pushSdkAnd->getLastErrorMsg();
     //        }
     //andriod push end
     //ios push start
     $sendIosInfo = array_merge(array('aps' => array("alert" => $content)), $this->getInfo());
     foreach ($channlIds as $channlId) {
         $irs = $this->pushSdkIos->pushMsgToSingleDevice($channlId, $sendIosInfo, $this->opts);
         //            if($irs === false) {
         $err['ios']['code'] = $this->pushSdkIos->getLastErrorCode();
         $err['ios']['msg'] = $this->pushSdkIos->getLastErrorMsg();
         //            }
     }
     //ToDo 批量推送有问题
     //        $irs = $this->pushSdkIos->pushBatchUniMsg($channlIds, array('aps'=>array("alert"=>$content)),array('opt'=>array('deploy_status'=>1)));
     //        if($irs === false) {
     //            $err['code'] = $this->pushSdkIos->getLastErrorCode();
     //            $err['msg'] = $this->pushSdkIos->getLastErrorMsg();
     //        }
     return $ars || $irs;
     //        ios push end
 }
コード例 #2
0
 private function pushAndroidAll()
 {
     // 创建SDK对象.
     $sdk = new PushSDK();
     //  $channelId = '3785562685113372034';
     // message content.
     $message = array('title' => 'Hi!', 'description' => "hello, wanhao来了.");
     // 设置消息类型为 通知类型.
     $opts = array('msg_type' => 1);
     // 向目标设备发送一条消息
     //$rs = $sdk -> pushMsgToSingleDevice($channelId, $message, $opts);
     $rs = $sdk->pushMsgToAll($message, $opts);
     // 判断返回值,当发送失败时, $rs的结果为false, 可以通过getError来获得错误信息.
     if ($rs === false) {
         print_r($sdk->getLastErrorCode());
         print_r($sdk->getLastErrorMsg());
     } else {
         // 将打印出消息的id,发送时间等相关信息.
         print_r($rs);
     }
 }
コード例 #3
0
 public function pushAndroidAll($param)
 {
     // 创建SDK对象.
     $sdk = new PushSDK();
     //  $channelId = '3785562685113372034';
     // message content.
     $message = array('title' => $param['title'], 'description' => $param['content'], 'custom_content' => array('uri' => $param['uri'], 'invalid' => $param['invalid']));
     // 设置消息类型为 通知类型.
     $opts = array('msg_type' => 1);
     // 向目标设备发送一条消息
     //$rs = $sdk -> pushMsgToSingleDevice($channelId, $message, $opts);
     $rs = $sdk->pushMsgToAll($message, $opts);
     // 判断返回值,当发送失败时, $rs的结果为false, 可以通过getError来获得错误信息.
     if ($rs === false) {
         print_r($sdk->getLastErrorCode());
         print_r($sdk->getLastErrorMsg());
     } else {
         // 将打印出消息的id,发送时间等相关信息.
         print_r($rs);
     }
 }
コード例 #4
0
ファイル: hello.php プロジェクト: fengyeno/fille
 *
 * ************************************************************************
 */
/**
 *
 * @file hello.php
 * @encoding UTF-8
 * 
 * 
 *         @date 2015年3月10日
 *        
 */
require_once '../sdk.php';
// 创建SDK对象.
$sdk = new PushSDK();
$channelId = '3785562685113372034';
// message content.
$message = array('title' => 'Hi!', 'description' => "hello, this message from baidu push service.");
// 设置消息类型为 通知类型.
$opts = array('msg_type' => 1);
// 向目标设备发送一条消息
$rs = $sdk->pushMsgToSingleDevice($channelId, $message, $opts);
// 判断返回值,当发送失败时, $rs的结果为false, 可以通过getError来获得错误信息.
if ($rs === false) {
    print_r($sdk->getLastErrorCode());
    print_r($sdk->getLastErrorMsg());
} else {
    // 将打印出消息的id,发送时间等相关信息.
    print_r($rs);
}
echo "done!";
コード例 #5
0
 public function actionPush()
 {
     $sdk = new PushSDK();
     $channelId = '4483825412066692748';
     $message = array('title' => 'Hi!.', 'description' => "杨老板卧槽");
     // 设置消息类型为 通知类型.
     $opts = array('msg_type' => 1);
     // 向目标设备发送一条消息
     $rs = $sdk->pushMsgToAll($message, $opts);
     //pushMsgToSingleDevice ( $channelId, $message, $opts );
     // 判断返回值,当发送失败时, $rs的结果为false, 可以通过getError来获得错误信息.
     if ($rs === false) {
         print_r($sdk->getLastErrorCode());
         print_r($sdk->getLastErrorMsg());
     } else {
         // 将打印出消息的id,发送时间等相关信息.
         print_r($rs);
     }
     echo "done!";
 }