PHP code example of qiucheng / dumeng

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

    

qiucheng / dumeng example snippets




use Dumeng\Client;

$config = [
    'android' => [
        'appkey' => 'xxxxxxx',
        'appMasterSecret' => 'xxxxxxxxx',
    ],
    'ios' => [
        'appkey' => 'xxxxxxxxx',
        'appMasterSecret' => 'xxxxxxxxx',
    ]
];
//参数二可以指定日志路径,若要关闭日志设置为空即可。new Client($config, null);
$Client = new Client($config);

$push = $Client->push();
$push->set_platform(['ios','android']); //设置推动端,必须要首先设置该参数
$push->set_type('broadcast');
$push->set_payload(['ios'=>['aaa'],'android'=>['bbb']]);
$push->send();

$push = $Client->push();
$push->status(['ios'=>'XXXX','android'=>'XXXX']);

$push = $Client->push();
$push->cancel(['ios'=>'XXXX','android'=>'XXXX']);

$push = $Client->push();
$push->upload(['ios'=>'XXXX','android'=>'XXXX']);