1. 安装
链接:https://github.com/jpush/jpush-api-php-client
2. 代码片段
<?php
namespace app\api\controller;
use JPush\Client;
use think\App;
use think\Controller;
class Push extends Base {
protected $appkey='';
protected $appsecret='';
public function __construct(App $app = null)
{
parent::__construct($app);
}
/*
调用jpush推送消息
$token 需要被推送消息的用户设备id
$msg 需要被推送给用户的信息
*/
public function jpush_msg($jpush_token='',$content,$param = array()){
$client = new Client($this->appkey, $this->appsecret);
$push = $client->push();
$message = array(
'title' => '',
'content_type' => 'text',
'extras' => $param,
);