首页 > 代码库 > 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 消息推送