首页 > 代码库 > cakephp 利用Pushapi扩展 进行app 消息推送
cakephp 利用Pushapi扩展 进行app 消息推送
public function push_designer_app($params) { $this->layout = false; $this->autoRender = false; //给APP推送 $pushconf = array( ‘app_key‘ => ‘??????‘, ‘master_secret‘ => ‘????‘ ); APP::import("vendor", ‘Pushapi/Pushapi‘);// require_once(APP . ‘Vendor‘ . DS . ‘Pushapi‘ . DS .‘Pushapi.php‘); if ( ($_SERVER[‘HTTP_HOST‘] == ‘www.ceshi.com‘) || ($_SERVER[‘HTTP_HOST‘] == ‘www.测试2.com‘)) { $Pushapi = new Pushapi( $pushconf , false ); }else{ $Pushapi = new Pushapi( $pushconf , TRUE ); } $params[‘registration_id‘] = $params[‘registration_id‘]; if(!empty($params[‘registration_id‘])) { $params[‘appname‘] = ‘你的app名字‘; $params[‘msg‘] = $params[‘title‘]; $params[‘params‘] = array(); $params[‘id‘] = mt_rand(11111,99999); $params[‘extras‘] = $params[‘extras‘]; $log = $Pushapi->push_msg($params); $data[‘status‘] = $log[‘status‘]; $data[‘push_msg‘] = json_encode($log[‘push_msg‘]); }else{ $params[‘appname‘] = ‘你的app名字‘; $params[‘msg‘] = $params[‘title‘]; $params[‘params‘] = array(); $params[‘id‘] = mt_rand(11111,99999); $params[‘extras‘] = $params[‘extras‘]; $log = $Pushapi->push_msg($params); $data[‘status‘] = $log[‘status‘]; $data[‘push_msg‘] = json_encode($log[‘push_msg‘]); } }
/** * 发app推送 */ private function _push($title=‘设计师公告消息(所有)‘, $registration_id=false) { if($registration_id){ $params[‘registration_id‘]=$registration_id; //电话号码 }else{ $params[‘type‘] = 1; //为所有人的时候 } $params[‘title‘]=$title; $params[‘extras‘] = array(); $rs = $this->push_designer_app($params); return $rs; }
$params[‘appname‘] = ‘设计师APP‘; $params[‘msg‘] = $params[‘title‘]; $params[‘params‘] = array(); $params[‘id‘] = mt_rand(11111,99999); $params[‘extras‘] = $params[‘extras‘]; $log = $Pushapi->push_msg($params);
cakephp 利用Pushapi扩展 进行app 消息推送
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。