1. Go to this page and download the library: Download maxsky/umeng-service 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/ */
try {
$broadcast = new AndroidBroadcast();
$broadcast->setAppMasterSecret('MasterSecret');
$broadcast->setPredefinedKeyValue('appkey', 'AppKey');
$broadcast->setPredefinedKeyValue('timestamp', time());
$broadcast->setPredefinedKeyValue('ticker', 'Android broadcast ticker');
$broadcast->setPredefinedKeyValue('title', '中文的 title');
$broadcast->setPredefinedKeyValue('text', 'Android broadcast text');
$broadcast->setPredefinedKeyValue('after_open', 'go_app');
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
$broadcast->setPredefinedKeyValue('production_mode', 'true');
// [optional] Set extra fields
$broadcast->setExtraField('test', 'helloworld');
$result = $broadcast->send();
if ($result['ret'] === 'SUCCESS') {
// 成功
}
} catch (UMengServiceException $e) {
Log::error('推送异常,错误消息:' . $e->getMessage());
throw new Exception('推送失败');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.