Esempio n. 1
0
function capi_jpush($uidarr, $message, $title = null, $extras = null)
{
    $client = new JPush(JPUSH_APP_KEY, JPUSH_MASTER_SECRET);
    try {
        $result = $client->push()->setPlatform(array('ios', 'android'))->addAlias($uidarr)->setNotificationAlert($message)->addAndroidNotification($message, $title, 1, $extras)->addIosNotification($message, JPUSH_IOS_SOUND, '+1', true, null, $extras)->send();
        if (D_BUG) {
            runlog('jpush', 'Push Success:' . json_encode($result));
        }
    } 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;
        */
        if (D_BUG) {
            runlog('jpush', 'Push Fail:' . json_encode(array('error' => $e)));
        }
    } 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;
        */
        if (D_BUG) {
            runlog('jpush', 'Push Fail:' . json_encode(array('ErrorMessage' => $e->getMessage(), 'IsResponseTimeout' => $e->isResponseTimeout)));
        }
    }
    //echo $br . '-------------' . $br;
}
 public function actionJPush()
 {
     $client = new JPush(Yii::app()->params['teacher_JPush']['app_key'], Yii::app()->params['teacher_JPush']['master_secret']);
     $result = $client->push()->setPlatform(array('ios', 'android'))->addAlias('alias1')->addTag('all')->setNotificationAlert('Hi, hello')->addAndroidNotification('Hi, android notification', 'notification title', 1, array("key1" => "value1", "key2" => "value2"))->addIosNotification("Hi, iOS notification", 'iOS sound', JPush::DISABLE_BADGE, true, 'iOS category', array("key1" => "value1", "key2" => "value2"))->setMessage("msg content", 'msg title', 'type', array("key1" => "value1", "key2" => "value2"))->setOptions(100000, 3600, null, false)->send();
     $message = "";
     //存储推送状态
     if ($result) {
         $res_arr = json_encode($result, true);
         if (isset($res_arr['error'])) {
             //如果返回了error则证明失败
             echo $res_arr['error']['message'];
             //错误信息
             $error_code = $res_arr['error']['code'];
             //错误码
             switch ($error_code) {
                 case 200:
                     $message = '发送成功!';
                     break;
                 case 1000:
                     $message = '失败(系统内部错误)';
                     break;
                 case 1001:
                     $message = '失败(只支持 HTTP Post 方法,不支持 Get 方法)';
                     break;
                 case 1002:
                     $message = '失败(缺少了必须的参数)';
                     break;
                 case 1003:
                     $message = '失败(参数值不合法)';
                     break;
                 case 1004:
                     $message = '失败(验证失败)';
                     break;
                 case 1005:
                     $message = '失败(消息体太大)';
                     break;
                 case 1008:
                     $message = '失败(appkey参数非法)';
                     break;
                 case 1020:
                     $message = '失败(只支持 HTTPS 请求)';
                     break;
                 case 1030:
                     $message = '失败(内部服务超时)';
                     break;
                 default:
                     $message = '失败(返回其他状态,目前不清楚额,请联系开发人员!)';
                     break;
             }
         } else {
             $message = "发送成功!";
         }
     } else {
         //接口调用失败或无响应
         $message = '接口调用失败或无响应';
     }
     echo "推送信息:{$message}";
 }
Esempio n. 3
0
 public function chat($platform)
 {
     $this->username = Yii::app()->user->username;
     $this->avatar = Yii::app()->user->avatar0;
     $this->sender = Yii::app()->user->userId;
     $jPush = new JPush($platform);
     if ($jPush->sendSingle($this->attributes)) {
         Yii::app()->getController()->send(0, Yii::t('UserModule.user', 'success'));
     } else {
         Yii::app()->getController()->send(1, Yii::t('UserModule.user', 'fail'));
     }
 }
Esempio n. 4
0
 /**
  * @param $app_id
  * @param $user_id
  * @param $msg_type
  * @param $msg_title
  * @param $alert_content
  * @return bool
  */
 public function pushMsg($app_id, $user_id, $msg_type, $msg_title, $alert_content)
 {
     if ($app_id == 10) {
         // 学员端jPush
         $app_key = Yii::app()->params['student_JPush']['app_key'];
         $masterSecret = Yii::app()->params['student_JPush']['master_secret'];
     } elseif ($app_id == 11) {
         // 教师端jPush
         $app_key = Yii::app()->params['teacher_JPush']['app_key'];
         $masterSecret = Yii::app()->params['teacher_JPush']['master_secret'];
     } else {
         return false;
     }
     $result = array();
     try {
         // 调用jPush API
         $client = new JPush($app_key, $masterSecret);
         $result = $client->push()->setPlatform(array('ios', 'android'))->addAlias($user_id)->addTag('all')->addAndroidNotification($alert_content, $msg_title, 1, array("msg_type" => $msg_type, "msg_title" => $msg_title))->addIosNotification($alert_content, $msg_title, '+1', true, 'iOS category', array("msg_type" => $msg_type, "msg_title" => $msg_title))->setOptions(100000, 3600, null, false)->send();
     } catch (Exception $e) {
         error_log($e);
         return false;
     }
     //        $message="";    //存储推送状态
     //        if($result){
     //            $res_arr = json_encode($result, true);
     //            if(isset($res_arr['error'])){                       //如果返回了error则证明失败
     //                $message  = $res_arr['error']['message'];          //错误信息
     //                $error_code     = $res_arr['error']['code'];             //错误码
     //                self::insertPush($error_code, $message);
     //            }else{
     //                $message="发送成功!";
     //                $error_code = 1111;
     //                self::insertPush($error_code, $message);
     //            }
     //        }else{      //接口调用失败或无响应
     //            $message = '接口调用失败或无响应';
     //            $error_code = 0000;
     //            self::insertPush($error_code, $message);
     //        }
     return true;
 }
Esempio n. 5
0
 /**
  * 更新关注表 goddess_common.follow
  *  
  * @param int $time
  * @param int $user_id
  * @param int $heroine_id
  * @param int $followed		关注
  * @param int $praised		赞
  * @param int $liking		送礼物 好感值
  * @return boolean
  */
 public function updateFollow($time, $user_id, $heroine_id, $followed = null, $praised = null, $liking = null)
 {
     $con_characters = Yii::app()->db_characters;
     if (isset($followed)) {
         $type = 1;
     } else {
         if (isset($praised)) {
             $type = 2;
         } else {
             if (isset($liking)) {
                 $type = 3;
             }
         }
     }
     $condition = NULL;
     $param = NULL;
     switch ($type) {
         case 1:
             $condition = 'followed';
             $param = $followed;
             break;
         case 2:
             $condition = 'praised';
             $param = $praised;
             break;
         case 3:
             $condition = 'liking';
             $linking_info = Liking::model()->getMaxLikingLvRow();
             if ($liking > $linking_info['max']) {
                 $liking = $linking_info['max'];
             }
             $param = $liking;
             if ($GLOBALS['__APPID'] == 10) {
                 //增加好感值触发剧情推送
                 JPush::model()->likePush($user_id, $heroine_id, $liking);
             }
             break;
         default:
             return -1;
     }
     try {
         $table_name = sprintf('follow_%02s', dechex($user_id % 256));
         $con_characters->createCommand()->update('follow', array($condition => $param), 'user_id=:UserId AND heroine_id=:heroine_id', array(':UserId' => $user_id, ':heroine_id' => $heroine_id));
         $ret = $con_characters->createCommand()->update($table_name, array($condition => $param), 'user_id=:UserId AND heroine_id=:heroine_id', array(':UserId' => $user_id, ':heroine_id' => $heroine_id));
     } catch (Exception $e) {
         error_log($e);
         return false;
     }
     return true;
 }
Esempio n. 6
0
 public function push_msg($msg)
 {
     require_once APPPATH . 'libraries/JPush/JPush.php';
     $app_key = 'd6c00aaba4220737c096b0f5';
     $master_secret = '6738878b5566b6a9275ac090';
     // 初始化
     $client = new JPush($app_key, $master_secret);
     // 简单推送示例
     $result = $client->push()->setPlatform('all')->addAllAudience()->setNotificationAlert($msg)->send();
     echo 'Result=' . json_encode($result);
     // 		// 完整的推送示例,包含指定Platform,指定Alias,Tag,指定iOS,Android notification,指定Message等
     // 		$result = $client->push()
     // 			->setPlatform(array('ios', 'android'))
     // 			->addAlias('alias1')
     // 			->addTag(array('tag1', 'tag2'))
     // 			->setNotificationAlert('Hi, JPush')
     // 			->addAndroidNotification('Hi, android notification', 'notification title', 1, array("key1"=>"value1", "key2"=>"value2"))
     // 			->addIosNotification("Hi, iOS notification", 'iOS sound', JPush::DISABLE_BADGE, true, 'iOS category', array("key1"=>"value1", "key2"=>"value2"))
     // 			->setMessage("msg content", 'msg title', 'type', array("key1"=>"value1", "key2"=>"value2"))
     // 			->setOptions(100000, 3600, null, false)
     // 			->send();
     // 		echo 'Result=' . json_encode($result);
     // 		// 指定推送短信示例(推送未送达的情况下进行短信送达, 该功能需预付短信费用, 并调用Device API绑定设备与手机号)
     // 		$result = $client->push()
     // 			->setPlatform('all')
     // 			->addTag('tag1')
     // 			->setNotificationAlert("Hi, JPush SMS")
     // 			->setSmsMessage('Hi, JPush SMS', 60)
     // 			->send();
     // 		echo 'Result=' . json_encode($result);
 }
Esempio n. 7
0
 /**
  * POST 话题回复
  */
 public function create_replyOp()
 {
     $model = Model();
     $m_theme = $model->table('circle_theme');
     $theme = $m_theme->where(array("theme_id" => $this->t_id))->select();
     $this->c_id = $theme[0]['circle_id'];
     $to_user_id = $theme[0]['member_id'];
     //        var_dump($this->c_id);
     //圈子信息
     $this->circleInfo();
     // 会员信息
     $this->memberInfo();
     // 不是圈子成员不能发帖
     if (!in_array($this->identity, array(1, 2, 3))) {
         output_error("您不是圈子成员");
     }
     // 话题信息
     $this->themeInfo();
     if (isset($_POST)) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["replycontent"], "require" => "true", "message" => '回复不能为空'));
         $error = $obj_validate->validate();
         if ($error != '') {
             output_error($error);
         } else {
             $model = Model();
             $insert = array();
             $insert['theme_id'] = $this->t_id;
             $insert['circle_id'] = $this->c_id;
             $insert['member_id'] = $this->member_info['member_id'];
             $insert['member_name'] = $this->member_info['member_name'];
             $insert['reply_content'] = circleCenterCensor($_POST['replycontent']);
             $insert['reply_addtime'] = time();
             $insert['is_closed'] = 0;
             // 回复楼层验证
             if ($this->r_id != '') {
                 $reply_info = Model()->table('circle_threply')->where(array('theme_id' => $this->t_id, 'reply_id' => $this->r_id))->find();
                 if (!empty($reply_info)) {
                     $insert['reply_replyid'] = $reply_info['reply_id'];
                     $insert['reply_replyname'] = $reply_info['member_name'];
                 }
             }
             $reply_id = $model->table('circle_threply')->insert($insert);
             if ($reply_id) {
                 // 话题被回复数增加 最后发言人发言时间
                 $update = array();
                 $update['theme_id'] = $this->t_id;
                 $update['theme_commentcount'] = array('exp', 'theme_commentcount+1');
                 $update['lastspeak_id'] = $this->member_info['member_id'];
                 $update['lastspeak_name'] = $this->member_info['member_name'];
                 $update['lastspeak_time'] = time();
                 $model->table('circle_theme')->update($update);
                 // 成员回复数增加 最后回复时间
                 $model->table('circle_member')->where(array('member_id' => $this->member_info['member_id'], 'circle_id' => $this->c_id))->update(array('cm_comcount' => array('exp', 'cm_comcount+1'), 'cm_lastspeaktime' => time()));
                 // set cookie of SEC
                 if (intval(C('circle_intervaltime')) > 0) {
                     setNcCookie('circle_intervaltime', true, intval(C('circle_intervaltime')));
                 }
                 if ($this->theme_info['member_id'] != $this->member_info['member_id']) {
                     // Experience for replyer
                     $param = array();
                     $param['member_id'] = $this->member_info['member_id'];
                     $param['member_name'] = $this->member_info['member_name'];
                     $param['circle_id'] = $this->c_id;
                     $param['theme_id'] = $this->t_id;
                     $param['type'] = 'reply';
                     $param['itemid'] = $this->t_id . ',' . $reply_id;
                     Model('circle_exp')->saveExp($param);
                     // Experience for releaser
                     $param = array();
                     $param['member_id'] = $this->theme_info['member_id'];
                     $param['member_name'] = $this->theme_info['member_name'];
                     $param['theme_id'] = $this->t_id;
                     $param['circle_id'] = $this->c_id;
                     $param['type'] = 'replied';
                     $param['itemid'] = $this->t_id;
                     Model('circle_exp')->saveExp($param);
                 }
                 $jpush = new JPush();
                 $extras = array();
                 $extras['push_type'] = "hasReply";
                 $extras['id'] = $this->t_id;
                 $extras['circle_id'] = $this->theme_info['circle_id'];
                 //  回复自己的帖子不推送
                 if ($to_user_id != $this->member_info['member_id']) {
                     $jpush->pushMessageByAlias($this->member_info['member_name'] . "发表了新的回帖", "有新的回贴", $extras, array($to_user_id));
                 }
                 output_data(array('success' => '回复成功'));
             } else {
                 output_error("回复失败");
             }
         }
     }
 }
Esempio n. 8
0
<?php

/**
 * 该示例主要为JPush Schedule API的调用示例
 * HTTP API文档:http://docs.jpush.io/server/rest_api_push_schedule/
 * PHP API文档:https://github.com/jpush/jpush-api-php-client/blob/master/doc/api.md#schedule-api
 */
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
require_once "../src/JPush/JPush.php";
$br = '<br/>';
$app_key = 'dd1066407b044738b6479275';
$master_secret = 'e8cc9a76d5b7a580859bcfa7';
// 初始化
$client = new JPush($app_key, $master_secret);
$payload = $client->push()->setPlatform("all")->addAllAudience()->setNotificationAlert("Hi, 这是一条定时发送的消息")->build();
// 创建一个2016-12-22 13:45:00触发的定时任务
$response = $client->schedule()->createSingleSchedule("每天14点发送的定时任务", $payload, array("time" => "2016-12-22 13:45:00"));
echo 'Result=' . json_encode($response) . $br;
// 创建一个每天14点发送的定时任务
$response = $client->schedule()->createPeriodicalSchedule("每天14点发送的定时任务", $payload, array("start" => "2016-12-22 13:45:00", "end" => "2016-12-25 13:45:00", "time" => "14:00:00", "time_unit" => "DAY", "frequency" => 1));
echo 'Result=' . json_encode($response) . $br;
// 更新指定的定时任务
$response = $client->schedule()->updatePeriodicalSchedule('89c984f4-a880-11e5-b41a-0021f652c102', null, true);
echo "Result=" . json_encode($response) . "\r\n";
// 获取定时任务列表
$response = $client->schedule()->getSchedules();
echo "Result=" . json_encode($response) . "\r\n";
<?php

/**
 * 该示例主要为JPush Push API的调用示例
 * HTTP API文档:http://docs.jpush.io/server/rest_api_v3_push/
 * PHP API文档:(待补充)
 */
require_once "../src/JPush/JPush.php";
$br = '<br/>';
$app_key = 'dd1066407b044738b6479275';
$master_secret = 'e8cc9a76d5b7a580859bcfa7';
// 初始化
$client = new JPush($app_key, $master_secret);
// 简单推送示例
$result = $client->push()->setPlatform('all')->addAllAudience()->setNotificationAlert('Hi, JPush')->send();
echo 'Result=' . json_encode($result) . $br;
// 完整的推送示例,包含指定Platform,指定Alias,Tag,指定iOS,Android notification,指定Message等
$result = $client->push()->setPlatform(array('ios', 'android'))->addAlias('alias1')->addTag(array('tag1', 'tag2'))->setNotificationAlert('Hi, JPush')->addAndroidNotification('Hi, android notification', 'notification title', 1, array("key1" => "value1", "key2" => "value2"))->addIosNotification("Hi, iOS notification", 'iOS sound', JPush::DISABLE_BADGE, true, 'iOS category', array("key1" => "value1", "key2" => "value2"))->setMessage("msg content", 'msg title', 'type', array("key1" => "value1", "key2" => "value2"))->setOptions(100000, 3600, null, false)->send();
echo 'Result=' . json_encode($result) . $br;
// 指定推送短信示例(推送未送达的情况下进行短信送达, 该功能需预付短信费用, 并调用Device API绑定设备与手机号)
$result = $client->push()->setPlatform('all')->addTag('tag1')->setNotificationAlert("Hi, JPush SMS")->setSmsMessage('Hi, JPush SMS', 60)->send();
echo 'Result=' . json_encode($result) . $br;
Esempio n. 10
0
 /**
  * POST 问题回复(回答)
  */
 public function create_answerOp()
 {
     // Reply function does close,throw error.
     if (!intval(C('circle_istalk'))) {
         output_error(L('circle_has_been_closed_reply'));
     }
     // checked cookie of SEC
     if (cookie(circle_intervaltime)) {
         output_error(L('circle_operation_too_frequent'));
     }
     // 问题信息
     $this->questionInfo();
     if (isset($_POST)) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["content"], "require" => "true", "message" => '回复不能为空'));
         $error = $obj_validate->validate();
         if ($error != '') {
             output_error($error);
         } else {
             $model = Model();
             $insert = array();
             $insert['theme_id'] = $this->q_id;
             $insert['circle_id'] = $this->c_id;
             $insert['member_id'] = $this->member_info['member_id'];
             $insert['member_name'] = $this->member_info['member_name'];
             $insert['reply_content'] = circleCenterCensor($_POST['content']);
             $insert['reply_addtime'] = time();
             $insert['is_closed'] = 0;
             // 回复楼层验证
             if ($this->r_id != '') {
                 $reply_info = Model()->table('circle_threply')->where(array('theme_id' => $this->q_id, 'reply_id' => $this->r_id))->find();
                 if (!empty($reply_info)) {
                     $insert['reply_replyid'] = $reply_info['reply_id'];
                     $insert['reply_replyname'] = $reply_info['member_name'];
                 }
             }
             $reply_id = $model->table('circle_threply')->insert($insert);
             if ($reply_id) {
                 // 话题被回复数增加 最后发言人发言时间
                 $update = array();
                 $update['theme_id'] = $this->q_id;
                 $update['theme_commentcount'] = array('exp', 'theme_commentcount+1');
                 $update['lastspeak_id'] = $this->member_info['member_id'];
                 $update['lastspeak_name'] = $this->member_info['member_name'];
                 $update['lastspeak_time'] = time();
                 $model->table('circle_theme')->update($update);
                 // 成员回复数增加 最后回复时间
                 $model->table('circle_member')->where(array('member_id' => $this->member_info['member_id'], 'circle_id' => $this->c_id))->update(array('cm_comcount' => array('exp', 'cm_comcount+1'), 'cm_lastspeaktime' => time()));
                 // set cookie of SEC
                 if (intval(C('circle_intervaltime')) > 0) {
                     setNcCookie('circle_intervaltime', true, intval(C('circle_intervaltime')));
                 }
                 if ($this->question_info['member_id'] != $this->member_info['member_id']) {
                     // Experience for replyer
                     $param = array();
                     $param['member_id'] = $this->member_info['member_id'];
                     $param['member_name'] = $this->member_info['member_name'];
                     $param['circle_id'] = $this->c_id;
                     $param['theme_id'] = $this->q_id;
                     $param['type'] = 'reply';
                     $param['itemid'] = $this->q_id . ',' . $reply_id;
                     Model('circle_exp')->saveExp($param);
                     // Experience for releaser
                     $param = array();
                     $param['member_id'] = $this->question_info['member_id'];
                     $param['member_name'] = $this->question_info['member_name'];
                     $param['theme_id'] = $this->q_id;
                     $param['circle_id'] = $this->c_id;
                     $param['type'] = 'replied';
                     $param['itemid'] = $this->q_id;
                     Model('circle_exp')->saveExp($param);
                 }
                 $jpush = new JPush();
                 $extras = array();
                 $extras['push_type'] = "hasAnswer";
                 $extras['id'] = $this->q_id;
                 //  回复自己的帖子不推送
                 if ($this->question_info['member_id'] != $this->member_info['member_id']) {
                     $jpush->pushMessageByAlias($this->member_info['member_name'] . "发表了新的回答", "有新的回答", $extras, array($this->question_info['member_id']));
                 }
                 output_data(array('code' => 201, 'success' => '回复成功'));
             } else {
                 output_error('回复失败');
             }
         }
     }
 }
Esempio n. 11
0
<?php

/**
 * 此示例为JPush Report API的调用示例
 * HTTP API文档:http://docs.jpush.io/server/rest_api_v3_report/
 * PHP API文档:https://github.com/jpush/jpush-api-php-client/blob/master/doc/api.md#report-api
 */
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
require_once "../src/JPush/JPush.php";
$br = '<br/>';
$app_key = 'dd1066407b044738b6479275';
$master_secret = 'e8cc9a76d5b7a580859bcfa7';
// 初始化
$client = new JPush($app_key, $master_secret);
// 获取送达统计
$response = $client->report()->getReceived(array('1150720279', '1492401191', '1150722083'));
// 也可以如此调用 ->getReceived('1150720279,1492401191,1150722083')
echo 'Result=' . json_encode($response) . $br;
// 获取消息统计
$response = $client->report()->getMessages('541778586,1235578218');
echo 'Result=' . json_encode($response) . $br;
// 获取用户统计
$response = $client->report()->getUsers('DAY', '2014-06-10', 3);
echo 'Result=' . json_encode($response) . $br;
Esempio n. 12
0
 private function dealVoice($voice)
 {
     $len = mb_strlen($voice, 'utf-8');
     if ($len > 3) {
         $navWord = mb_substr($voice, 0, 3, 'utf-8');
         if ($navWord == "导航到") {
             $len = mb_strlen($voice, 'utf-8');
             $navWord = mb_substr($voice, 3, $len - 3, 'utf-8');
             $geourl = "http://api.map.baidu.com/geocoder/v2/?ak=m9fCLsMnPDsla4lTuKGNsw6c&callback=renderOption&output=xml&address={$navWord}";
             $apistr = file_get_contents($geourl);
             //读取文件
             $apiobj = simplexml_load_string($apistr);
             //xml解析
             $lat = $apiobj->result->location->lat;
             $lng = $apiobj->result->location->lng;
             $br = '<br/>';
             $app_key = 'ad2add0d7bafaab683ca3b16';
             $master_secret = '2009611fff8213ed1bd0c3a6';
             // 初始化
             $client = new JPush($app_key, $master_secret);
             //$label='999899';
             // 简单推送示例
             $result = $client->push()->setPlatform('all')->addAllAudience()->setNotificationAlert("导航到" . "{$navWord}" . "(" . $lng . "," . $lat . ")")->send();
             echo 'Result1=' . json_encode($result) . $br;
             //JPUSH应用
             $app_key = '5f1e36080805488ab8f22631';
             $master_secret = '2bd1c368081d8ad860afb867';
             // 初始化
             $client = new JPush($app_key, $master_secret);
             //$label='999899';
             // 简单推送示例
             $result = $client->push()->setPlatform('all')->addAllAudience()->setNotificationAlert("导航到" . "{$navWord}" . "(" . $lng . "," . $lat . ")")->send();
             echo 'Result0=' . json_encode($result) . $br;
             $contentStr = "位置已发送,如果长时间未收到,可能是网络原因,请重试!";
         } else {
             $contentStr = "您的语音有误,请重新输入";
         }
     } else {
         $contentStr = "您的语音有误,请重新输入";
     }
     return $contentStr;
 }
Esempio n. 13
0
error_reporting(E_ALL | E_STRICT);
require_once "../src/JPush/JPush.php";
$br = '<br/>';
$br = "\r\n";
$app_key = 'dd1066407b044738b6479275';
$master_secret = 'e8cc9a76d5b7a580859bcfa7';
$TAG1 = "tag1";
$TAG2 = "tag2";
$TAG3 = "tag3";
$TAG4 = "tag4";
$ALIAS1 = "alias1";
$ALIAS2 = "alias2";
$REGISTRATION_ID1 = "0900e8d85ef";
$REGISTRATION_ID2 = "0a04ad7d8b4";
// 初始化
$client = new JPush($app_key, $master_secret);
// 获取指定设备的Mobile,Alias,Tags等信息
$result = $client->device()->getDevices($REGISTRATION_ID1);
echo 'Result=' . json_encode($result) . $br;
// 获取Tag列表
$result = $client->device()->getTags();
echo 'Result=' . json_encode($result) . $br;
// 判断指定RegistrationId是否在指定Tag中
$result = $client->device()->isDeviceInTag($REGISTRATION_ID1, $TAG1);
echo 'Result=' . json_encode($result) . $br;
// 获取指定Alias下的设备
$result = $client->device()->getAliasDevices($ALIAS1);
echo 'Result=' . json_encode($result) . $br;
// 更新指定的设备的Alias(亦可以增加/删除Tags)
$result = $client->device()->updateDevice($REGISTRATION_ID1, $ALIAS1);
echo 'Result=' . json_encode($result) . $br;