PHP code example of jimchen / umeng
1. Go to this page and download the library: Download jimchen/umeng 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/ */
jimchen / umeng example snippets
use Hedeqiang\UMeng\Android;
use Hedeqiang\UMeng\IOS;
// Android
$config = [
'appKey' => '5b1df1**************',
'appMasterSecret' => 'i7tzdarsw************',
'production_mode' => true,
];
// IOS
$ios_config = [
'appKey' => '5b1df0d1************',
'appMasterSecret' => 'fa9ry9kd*********',
'production_mode' => true,
]
$android = new Android($config));
$ios = new IOS($ios_config);
$params = [
'alias_type' => 'APP',
'alias' => 1,
"ticker" => "测试提示文字",
"title" => "测试标题",
"text" => "测试文字描述",
"after_open" => "go_app",
"description" => "测试广播通知-Android",
];
$response = $android->sendAndroidCustomizedcast($params);
$params = [
"ticker" => "测试提示文字",
"title" => "测试标题",
"text" => "测试文字描述",
"after_open" => "go_app",
];
$extra = [
'key1' => 'val1',
'key2' => 'val2',
];
$response = $android->sendAndroidBroadcast($params, $extra);
$params = [
"device_tokens" => "测试提示文字",
"display_type" => "notification", // message:消息 notification:通知
//"custom" => '自定义custom',
//以下内容为 notification 必填项
"ticker" => "测试提示文字",
"title" => "测试标题",
"text" => "测试文字描述",
"after_open" => "go_app",
];
//可选项
$extra = [
'key1' => 'val1',
'key2' => 'val2',
];
$response = $android->sendAndroidUnicast($params, $extra);
$params = [
"ticker" => "测试提示文字",
"title" => "测试标题",
"text" => "测试文字描述",
"after_open" => "go_app",
];
//
$content = "aa" . "\n" . "bb";
$response = $android->sendAndroidFilecast($params, $content);
$params = [
"ticker" => "测试提示文字",
"title" => "测试标题",
"text" => "测试文字描述",
"after_open" => "go_app",
];
//
$filter = [
'where' => [
'and' => [
'tag' => 'test',
'tag1' => 'test2',
],
],
];
$response = $android->sendAndroidGroupcast($filter, $params);
$params = [
"ticker" => "测试提示文字",
"title" => "测试标题",
"text" => "测试文字描述",
"after_open" => "go_app",
'alias_type' => 'APP',
];
$content = "aa" . "\n" . "bb";
$response = $android->sendAndroidCustomizedcastFileId($params, $content);
$params = [
'alert' => [
'title' => 'title',
'body' => 'body',
], //字符串或者JSON
"description" => "测试广播通知-iOS"
];
$customized = [
'key' => 'jey',
]; //可选
$response = $ios->sendIOSBroadcast($params, $customized);
$params = [
'device_tokens' => 'token',
'alert' => [
'title' => 'title',
'body' => 'body',
], //字符串或者JSON
"description" => "测试单播消息-iOS"
];
$customized = [
'key' => 'jey',
]; //可选
$response = $ios->sendIOSUnicast($params, $customized);
$params = [
'device_tokens' => 'token',
'alert' => [
'title' => 'title',
'body' => 'body',
], //字符串或者JSON
"description" => "测试filecast文件通知-iOS"
];
$content = "aa" . "\n" . "bb";
$response = $ios->sendIOSFilecast($params, $content);
$params = [
'alert' => [
'title' => 'title',
'body' => 'body',
], //字符串或者JSON
"description" => "测试组播通知-iOS"
];
$filter = [
'where' => [
'and' => [
'tag' => 'test',
'tag1' => 'test2',
],
],
];
$response = $ios->sendIOSGroupcast($filter, $params);