PHP code example of silentlun / yii2-getui-v2

1. Go to this page and download the library: Download silentlun/yii2-getui-v2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silentlun / yii2-getui-v2 example snippets


    'components' => [
        'getui' => [
            'class' => 'silentlun\getui\Push',
            'appName' => 'com.xxx.app', //APP包名
            'appId' => 'xxxx', //个推APPID
            'appKey' => 'xxxxx', //个推APPKEY
            'masterSecret' => 'xxxxx', //个推masterSecret
            'host' => 'https://restapi.getui.com',
        ],
    ],
 
    public function actionPush()
    {
        $data = [
            'title' => '系统通知标题',
            'body' => '系统通知内容',
            'payload' => [], //自定义参数
        ];
        
        $result = Yii::$app->getui->pushToAll($data);
        if ($result['code'] == 0) {
            echo 'success';
        } else {
            echo $result['msg'];
        }
    }
    
 
    public function actionPush()
    {
        $data = [
            'title' => '系统通知标题',
            'body' => '系统通知内容',
            'payload' => [], //自定义参数
        ];
        $cid = 'd6d5f5df5d8e6b4eb9557bbdd98bb449';
        $result = Yii::$app->getui->pushToSingleByCid($cid, $data);
        if ($result['code'] == 0) {
            echo 'success';
        } else {
            echo $result['msg'];
        }
    }
    

    public function actionPush()
    {
        $data = [
            'title' => '系统通知标题',
            'body' => '系统通知内容',
            'payload' => [], //自定义参数
        ];
        $cids = [
            'd6d5f5df5d8e6b4eb9557bbdd98b34c9', 
            'd6d5f5df5d8e6b4eb9557bbdd98b4444',
            'd6d5f5df5d8e6b4eb9557bbdd98b4444',
        ];
        
        $result = Yii::$app->getui->pushToListByCid($cids, $data);
        if ($result['code'] == 0) {
            echo 'success';
        } else {
            echo $result['msg'];
        }
    }
    

php composer