PHP code example of haiaouang / mipush

1. Go to this page and download the library: Download haiaouang/mipush 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/ */

    

haiaouang / mipush example snippets


    'providers' => [
        /**
         * 添加供应商
         */
        Hht\Pusher\PusherServiceProvider::class,
        /**
         * 添加供应商
         */
        Hht\Support\ServiceProvider::class,
    ],



return [
    'default' => 'mipush',
    'launchers' => [
        'mipush' => [
            'driver' => 'mipush',
            'reg_url' => 'https://api.xmpush.xiaomi.com/v3/message/regid',
            'alias_url' => 'https://api.xmpush.xiaomi.com/v3/message/alias',
            'topic_url' => 'https://api.xmpush.xiaomi.com/v3/message/topic',
            'multi_topic_url' => 'https://api.xmpush.xiaomi.com/v3/message/multi_topic',
            'all_url' => 'https://api.xmpush.xiaomi.com/v3/message/all',
            'exist_url' => 'https://api.xmpush.xiaomi.com/v2/schedule_job/exist',
            'delete_url' => 'https://api.xmpush.xiaomi.com/v2/schedule_job/delete',

            'android' => [
                'bundle_id' => '',
                'app_id' => '',
                'app_key' => '',
                'app_secret' => ''
            ],

            'ios' => [
                'bundle_id' => '',
                'app_id' => '',
                'app_key' => '',
                'app_secret' => ''
            ],
            'prefix' => env( 'MIPUSH_PREFIX' , 'test_' )
        ],
    ],
];

    //苹果message -- 具体参数配置清查看小米推送文档
    $message = new \Hht\MiPush\Builder\IOSBuilder();
    
    //安卓message -- 具体参数配置清查看小米推送文档
    $message = new \Hht\MiPush\Builder\Builder();

    Push::launcher('mipush')->setAlias('aaa')->send($message);

    Push::launcher('mipush')->setAliases('aaa', 'bbb', 'ccc')->send($message);
    //或
    Push::launcher('mipush')->setAliases(['aaa', 'bbb', 'ccc'])->send($message);

    Push::launcher('mipush')->setId('aaa')->send($message);

    Push::launcher('mipush')->setIds('aaa', 'bbb', 'ccc')->send($message);
    //或
    Push::launcher('mipush')->setIds(['aaa', 'bbb', 'ccc'])->send($message);

    Push::launcher('mipush')->setTopic('aaaa')->send($message);

    Push::launcher('mipush')->setAll(true)->send($message);