composer安装
进入PHP项目目录,执行
composer require jpush/jpush
安装成功后tp5测试
<?php
namespace app\jpush\controller;
class IndexController
{
static $app_key="";
static $master_secret="";
/*
* 测试推送
*/
public function test() {
$app_key=self::$app_key;
$master_secret=self::$master_secret;
$client = new \JPush\Client($app_key,$master_secret);
$pusher = $client->push();
$pusher->setPlatform('all');
$pusher->addAllAudience();
$pusher->setNotificationAlert('test,JPush---'.date("Y-m-d H:i:s"));
try {
$res=$pusher->send