目录如下
在libraries中引入极光api
在libraties中创建jpush.php文件,代码如下
public function send($_msg_body = 'Hello, JPush', $_alias = 'all', $_platform = 'all'){
$client = new \JPush\Client($this->_key, $this->_secret);
$pusher = $client->push();
$pusher->setPlatform($_platform );
if(strtolower($_alias) == 'all'){
$pusher->addAllAudience();
}else{
$pusher->addAlias($_alias);
}
$pusher->setNotificationAlert($_msg_body);
try {
$_rs = $pusher->send();
} catch (\JPush\Exceptions\JPushException $e) {
$_rs = $e;
}
return $_rs;
}
控制器直接调用该方法即可,传入相关的账号信息。。