目錄如下
在libraries中引入極光api
1497436800(1).png
在libraties中創(chuàng)建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;
}
控制器直接調(diào)用該方法即可刹碾,傳入相關(guān)的賬號(hào)信息指么。叔壤。