我的产品,点击产品对应的Push服务,点击“移动应用详情”获取)
    private $tokenUrl = "https://login.cloud.huawei.com/oauth2/v2/token"; //获取认证Token的URL
    private $apiUrl = "https://api.push.hicloud.com/pushsend.do"; //应用级消息下发API
    private $accessToken;//下发通知消息的认证Token
    private $tokenExpiredTime;  //accessToken的过期时间
    private $void;//参数组

    /**
     * [void 参数设置]
     * @Author   Jerry
     * @DateTime 2018-10-31T08:45:37+0800
     * @Example  eg:
     * @param    [type]                   $key   [description]
     * @param    [type]                   $value [description]
     * @return   [type]                          [description]
     */
    private function void($key, $value)
    {
        $this->void[$key] = $value;
    }
    
    /**
     * [send 数据推送方法]
     * @Author   Jerry
     * @DateTime 2018-11-12T20:25:51+0800
     * @Example  eg:
     * @param    array                    $deviceTokens [description]
     * @param    string                   $title        [description]
     * @param    string                   $content      [description]
     * @param    integer                  $actionType   [description]
     * @param    integer                  $msgType      [description]
     * @param    array                    $params       [description]
     * @return   [type]                                 [description]
     */
    public function sends($deviceTokens=[],$title='',$content='',$actionType=3,$msgType=3,$params=[])
    {
        $this->refreshToken();
        return $this->sendPushMessage($deviceTokens,$title,$content,$actionType,$msgType,$params);
    }

    /**
     * [refreshToken 获取ke下发通知消息的认证Token]
     * @Author   Jerry
     * @DateTime 2018-10-31T08:44:39+0800
     * @Example  eg:
     * @return   [type]                   [description]
     */
    private function refreshToken()
    {
        $client_secret = $this->appSecret;
        $client_id = $this->appId;

        $this->void = null;

        $this->void(CURLOPT_POST, 1);
        $this->void(CURLOPT_HEADER, false);
        $this->void(CURLOPT_RETURNTRANSFER, true);
        $this->void(CURLOPT_CONNECTTIMEOUT, 5000);
        $this->void(CURLOPT_TIMEOUT, 5000);
        $this->void(CURLOPT_POSTFIELDS, 'grant_type=client_credentials&client_secret=' . $client_secret . '&client_id=' . $client_id);

        $response = $this->send($this->tokenUrl, $this->void);
        $obj = json_decode($response);
        $this->accessToken = $obj->access_token;
        $this->tokenExpiredTime = $this->msectime() + $obj->expires_in - 5 * 60 * 1000;
    }

    /**
     * [sendPushMessage 发送Push消息]
     * @Author   Jerry
     * @DateTime 2018-10-31T08:43:47+0800
     * @Example  eg:
     * @param    array                    $deviceTokens [设置TOKEN]
     * @param    string                   $title        [推送标题]
     * @param    string                   $content      [推送内容]
     * @param    integer                  $actionType   [行为类型]
     * @param    integer                  $msgType      [信息类型]
     * @param    array                    $params       [附加参数]
     * @return   [type]                                 [description]
     */
    private function sendPushMessage($deviceTokens=[],$title='',$content='',$actionType=3,$msgType=3,$params=[])
    {
        if ($this->tokenExpiredTime <= $this->msectime()) {
            $this->refreshToken();
        }
        /*PushManager.requestToken为客户端申请token的方法,可以调用多次以防止申请token失败*/
        /*PushToken不支持手动编写,需使用客户端的onToken方法获取*/
        if(!$deviceTokens){
            $deviceTokens[] = 'XXXXXXXXX';## 测试用的设备TOKEN
        }
        // die;
        // dump($deviceTokens);
        //仅通知栏消息需要设置标题和内容,透传消息key和value为用户自定义
        $body = [
            'title'         => $title?$title:'Push message title',//消息标题
            'content'       => $content?$content:'Push message content',//消息标题
        ];
        $param = [
            'appPkgName'    =>isset($params['appPkgName'])?$params['appPkgName']:'cn.honor.qinxuan',//定义需要打开的appPkgName
            'intent'        =>'#Intent;action=cn.honor.qinxuan.action.msg;package=cn.honor.qinxuan;end',

        ];
        $action = [
            'param'         =>$param,//消息点击动作参数
            'type'          =>$actionType?$actionType:3,//1 自定义行为:行为由参数intent定义2 打开URL:URL地址由参数url定义3 打开APP:默认值,打开App的首页 注意:富媒体消息开放API不支持。
            

        ];

        $msg = [
            'action'        =>$action,//消息点击动作
            'type'          =>$msgType?$msgType:3,//1 透传异步消息3 系统通知栏异步消息注意:2和4以后为保留后续扩展使用
            'body'          =>$body
        ];
        $ext = [
            'biTag'         =>'Trump',//设置消息标签,如果带了这个标签,会在回执中推送给CP用于检测某种类型消息的到达率和状态。注意:BigTag不能携带下面几个保留字符:逗号‘,’,竖线‘|’,长度不能超过100个字符。
            'icon'          => '',//自定义推送消息在通知栏的图标,value为一个公网可以访问的URL
            "customize" =>[$params['customize']],##扩展信息
        ];
        
        
        
        #华为PUSH消息总结构体
        $hps = [
            'msg'           =>$msg,
            'ext'           =>$ext,

        ];

        $payload = [
            'hps'           =>$hps, 

        ];

        $postBody = 'access_token=' . urlencode($this->accessToken) . '&nsp_svc=' . urlencode('openpush.message.api.send') . '&nsp_ts=' . (int)urlencode($this->msectime()/1000)
            . '&device_token_list=' . urlencode(json_encode($deviceTokens)) . '&payload=' . urlencode(json_encode($payload));
        $postUrl = $this->apiUrl . '?nsp_ctx=' . urlencode("{\"ver\":\"1\", \"appId\":\"" . $this->appId . "\"}");
        $this->void = null;
        $this->void(CURLOPT_POST, 1);
        $this->void(CURLOPT_HEADER, false);
        $this->void(CURLOPT_RETURNTRANSFER, 1);
        $this->void(CURLOPT_BINARYTRANSFER, 1);
        $this->void(CURLOPT_CONNECTTIMEOUT, 5000);
        $this->void(CURLOPT_TIMEOUT, 5000);
        $this->void(CURLOPT_POSTFIELDS, $postBody);
        return $response = $this->send($postUrl, $this->void);
    }


   
}