cakephp 利用Pushapi扩展 进行app 消息推送
Posted 小白兔晒黑了
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 消息推送的主要内容,如果未能解决你的问题,请参考以下文章
在 cakephp 2.x 中如何使用连接表获取第三个表数据?