PHP实现极光推送的方法

直接下载PHPdemo 直接运行代码就可以推送啦 当然前提要客户端 要写好极光推送sdk

核心代码
<pre>
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
require_once("../src/JPush/JPush.php");

$br = '<br/>';
$app_key = 'a1fe2663521eabaffdab2768';
$master_secret = '34143ac8f0bf5cd029bd39be';

$message=$_POST['message'];
//别名就是手机号
$tel=$_POST['tel'];
$type=$_POST['type'];
// 初始化
$client = new JPush($app_key, $master_secret);

// 别名推送
if($type!=0){
$result = $client->push()
->addAlias($tel)
->setPlatform('all')
->setNotificationAlert($message)
->send();
}else{
$result = $client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert($message)
->send();
}

 

</pre>

 

posted @ 2019-11-12 14:26  newmiracle宇宙  阅读(3344)  评论(0)    收藏  举报