PHP code example of libaocai / laravel-getui

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

    

libaocai / laravel-getui example snippets


php artisan vendor:publish --provider="Laravel/Getui/GetuiServiceProvider"

private function notificationSingle()
    {
        $data = [
            'network_type' => 0,
            'client_id' => 'c3024643a24c11bd3762d437c9103a42',
            'content' => '单人推送内容',
            'title' => '单人推送标题',
            'text' => '单人推送文本',
            'is_ring' => true,
            'is_vibrate' => true,
            'logo' => '',
            'logo_url' => ''
        ];
        // 第一个参数:
        Getui::pushToSingle('notification', $data);
    }

    $data = [
        'title' => '测试推送',
        'text' => '哈哈哈',
        'content' => '内容',
        'is_ring' => true,
        'is_vibrate' => true,
        'is_clearable' => true,
        'url' => 'http://www.juejin.im',
        'client_id' => 'c3024643a24c11bd3762d437c9103a42',
        'network_type' => 0
    ];
    
    Getui::pushToSingle('link', $data);

		$data = [
            'network_type' => 0,
            'transmission_type' => 2,
            'client_id' => 'c3024643a24c11bd3762d437c9103a42',
            'content' => '透传内容-单推1'
        ];
        Getui::pushToSingle('transmission', $data);

        $data = [
            'client_id_list' => [
                'c3024643a24c11bd3762d437c9103a42',
            ],
            'network_type' => 0,
            'content' => '多推内容',
            'title' => '多推标题',
            'text' => '多推文本',
            'is_ring' => true,
            'is_vibrate' => true,
            'logo' => '',
            'logo_url' => ''
        ];
        
        Getui::pushToList('notification', $data);

        $data = [
            'client_id_list' => [
                'c3024643a24c11bd3762d437c9103a42',
            ],
            'network_type' => 0,
            'title' => '多推连接标题',
            'text' => '多推连接文本',
            'is_ring' => true,
            'is_vibrate' => true,
            'is_clearable' => true,
            'url' => 'https://www.baidu.com'
        ];

        Getui::pushToList('link', $data);

$data = [
    'network_type' => 0,
    'transmission_type' => 2,
    'client_id_list' => [
        'c3024643a24c11bd3762d437c9103a42'
    ],
    'content' => '透传内容-多推'
];
Getui::pushToList('transmission', $data);

$data = [
    'title' => '网页推送',
    'text' => '网页推送文本',
    'is_ring' => true,
    'is_vibrate' => true,
    'url' => 'http://www.baidu.com',
    'is_clearable' => true
];

Getui::pushToApp('link', $data);

$data = [
    'title' => '测试推送12111',
    'text' => '哈哈哈1',
    'content' => '内容511121322',
    'is_ring' => true,
    'is_vibrate' => true,
    'logo' => '',
    'logo_url' => 'http://wwww.igetui.com/logo.png'
];

Getui::pushToApp('notification', $data);

$data = [
    'transmission_type' => 2,
    'content' => '透传内容-全量6'
];
$res = Getui::pushToApp('transmission', $data);

		$data = [
            'network_type' => 0,
            'transmission_type' => 2,
            'client_id_list' => [
                'c3024643a24c11bd3762d437c9103a42'
            ],
            'content' => '透传内容-多推1'
        ];
        Getui::pushToList('transmission', $data);

// 自定义数据
$content = '自定义消息文本1243';
$custom = [
    'keyId' => 1,
    'keyType' => 111199,
    'msg' => $content
];
$data = [
    'title' => '自定义消息标题-122',
    'transmission_type' => 2,
    'function' => 'json_encode',
    'content' => $content,
    'custom_data' => $custom,
    'custom_fields' => [
        'keyId', 'keyType'
    ],
    'speed' => 100, // 可选参数:定速推送 若设置100,则个推控制下发速度在100条/秒左右 默认无表示不定速.
];

Getui::pushToApp('transmission', $data);

// 自定义数据
$content = [
    'keyId' => 1,
    'keyType' => 111199
];
$data = [
    'title' => '自定义消息iOS',
    'network_type' => 0,
    'transmission_type' => 2,
    'client_id' => 'c3024643a24c11bd3762d437c9103a42',
    'content' => json_encode($content) // 自定义数据加密 接收端需要按照同样方式解密
];
Getui::pushToSingle('transmission', $data);

$data = [
    'title' => '自定义消息iOS',
    'network_type' => 0,
    'transmission_type' => 2,
    'client_id_list' => [
        'c3024643a24c11bd3762d437c9103a42'
    ],
    'content' => json_encode($content) // 自定义数据加密 接收端需要按照同样方式解密
];
Getui::pushToList('transmission', $data);