├── README.md
├── composer.json
├── getui
├── IGt.Batch.php
├── IGt.Push.php
├── demo.php
├── exception
│ ├── GtException.php
│ └── RequestException.php
├── igetui
│ ├── IGt.APNPayload.php
│ ├── IGt.AppMessage.php
│ ├── IGt.ListMessage.php
│ ├── IGt.Message.php
│ ├── IGt.MultiMedia.php
│ ├── IGt.Req.php
│ ├── IGt.SingleMessage.php
│ ├── IGt.TagMessage.php
│ ├── IGt.Target.php
│ ├── template
│ │ ├── IGt.APNTemplate.php
│ │ ├── IGt.BaseTemplate.php
│ │ ├── IGt.LinkTemplate.php
│ │ ├── IGt.NotificationTemplate.php
│ │ ├── IGt.NotyPopLoadTemplate.php
│ │ ├── IGt.RevokeTemplate.php
│ │ ├── IGt.StartActivityTemplate.php
│ │ ├── IGt.TransmissionTemplate.php
│ │ └── notify
│ │ │ ├── IGt.Notify.php
│ │ │ └── SmsMessage.php
│ └── utils
│ │ ├── ApiUrlRespectUtils.php
│ │ ├── ApnsUtils.php
│ │ ├── AppConditions.php
│ │ ├── GTConfig.php
│ │ ├── HttpManager.php
│ │ ├── LangUtils.php
│ │ └── LogUtils.php
├── payload
│ ├── Payload.php
│ └── VOIPPayload.php
└── protobuf
│ ├── encoding
│ └── pb_base128.php
│ ├── pb_message.php
│ ├── reader
│ ├── pb_input_reader.php
│ └── pb_input_string_reader.php
│ └── type
│ ├── pb_bool.php
│ ├── pb_bytes.php
│ ├── pb_enum.php
│ ├── pb_int.php
│ ├── pb_scalar.php
│ ├── pb_signed_int.php
│ └── pb_string.php
└── src
├── Constants
└── TemplateConstants.php
├── Facade
└── Getui.php
├── GetuiService.php
├── GetuiServiceProvider.php
├── TestController.php
├── Traits
├── TemplateTrait.php
└── ValidateTrait.php
└── config
└── getui.php
/README.md:
--------------------------------------------------------------------------------
1 | # 欢迎使用 Laravel扩展包 laravel-getui
2 | [](https://packagist.org/packages/Lysice/laravel-getui)
3 | [](https://packagist.org/packages/Lysice/laravel-getui)
4 | [](https://packagist.org/packages/Lysice/laravel-getui)
5 | [](https://packagist.org/packages/Lysice/laravel-getui)
6 |
7 | **网上有一款shaozeming/laravel-getui,自己在lumen下用,无奈报错依赖出问题,于是自己写了一款。**
8 |
9 |
10 | # 主要功能
11 |
12 | ## 单人推送/多人推送/全量推送/推送任务撤回(待开发)
13 |
14 | ### 支持模板
15 |
16 | #### 透传模板(自定义消息)
17 |
18 | #### 通知模板(打开应用首页)
19 |
20 | #### 通知模板 (打开浏览器网页)
21 |
22 | #### 通知模板 (打开应用内页面)
23 |
24 |
25 |
26 | ### 安装
27 |
28 | ` composer require lysice/laravel-getui `
29 |
30 |
31 | ### 发布配置
32 |
33 | `php artisan vendor:publish --provider="Lysice/Getui/GetuiServiceProvider"`
34 |
35 | ### 给 `config/app.php` 添加服务提供者
36 | providers 数组中添加:
37 |
38 | `Lysice\Getui\GetuiServiceProvider::class`
39 |
40 | ### 使用
41 | #### 1.单推
42 | ##### 1-1单推-通知打开应用首页
43 | private function notificationSingle()
44 | {
45 | $data = [
46 | 'network_type' => 0,
47 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
48 | 'content' => '单人推送内容',
49 | 'title' => '单人推送标题',
50 | 'text' => '单人推送文本',
51 | 'is_ring' => true,
52 | 'is_vibrate' => true,
53 | 'logo' => '',
54 | 'logo_url' => ''
55 | ];
56 | // 第一个参数:
57 | Getui::pushToSingle('notification', $data);
58 | }
59 | ##### 1-2 单推-通知打开链接
60 | $data = [
61 | 'title' => '测试推送',
62 | 'text' => '哈哈哈',
63 | 'content' => '内容',
64 | 'is_ring' => true,
65 | 'is_vibrate' => true,
66 | 'is_clearable' => true,
67 | 'url' => 'http://www.juejin.im',
68 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
69 | 'network_type' => 0
70 | ];
71 |
72 | Getui::pushToSingle('link', $data);
73 |
74 | ##### 1-3 单推-透传模板
75 | $data = [
76 | 'network_type' => 0,
77 | 'transmission_type' => 2,
78 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
79 | 'content' => '透传内容-单推1'
80 | ];
81 | Getui::pushToSingle('transmission', $data);
82 |
83 | #### 2 多推
84 | ##### 2-1 多推-通知打开应用首页
85 | $data = [
86 | 'client_id_list' => [
87 | 'c3024643a24c11bd3762d437c9103a42',
88 | ],
89 | 'network_type' => 0,
90 | 'content' => '多推内容',
91 | 'title' => '多推标题',
92 | 'text' => '多推文本',
93 | 'is_ring' => true,
94 | 'is_vibrate' => true,
95 | 'logo' => '',
96 | 'logo_url' => ''
97 | ];
98 |
99 | Getui::pushToList('notification', $data);
100 |
101 | ##### 2-2 多推-通知模板-打开链接
102 | $data = [
103 | 'client_id_list' => [
104 | 'c3024643a24c11bd3762d437c9103a42',
105 | ],
106 | 'network_type' => 0,
107 | 'title' => '多推连接标题',
108 | 'text' => '多推连接文本',
109 | 'is_ring' => true,
110 | 'is_vibrate' => true,
111 | 'is_clearable' => true,
112 | 'url' => 'https://www.baidu.com'
113 | ];
114 |
115 | Getui::pushToList('link', $data);
116 |
117 | ##### 2-3 多推-透传消息
118 | $data = [
119 | 'network_type' => 0,
120 | 'transmission_type' => 2,
121 | 'client_id_list' => [
122 | 'c3024643a24c11bd3762d437c9103a42'
123 | ],
124 | 'content' => '透传内容-多推'
125 | ];
126 | Getui::pushToList('transmission', $data);
127 |
128 | #### 3 全量推送
129 | ##### 3-1 全量推送-通知模板-打开链接
130 | $data = [
131 | 'title' => '网页推送',
132 | 'text' => '网页推送文本',
133 | 'is_ring' => true,
134 | 'is_vibrate' => true,
135 | 'url' => 'http://www.baidu.com',
136 | 'is_clearable' => true
137 | ];
138 |
139 | Getui::pushToApp('link', $data);
140 |
141 | ##### 3-2 全量推送-通知模板-打开应用首页
142 | $data = [
143 | 'title' => '测试推送12111',
144 | 'text' => '哈哈哈1',
145 | 'content' => '内容511121322',
146 | 'is_ring' => true,
147 | 'is_vibrate' => true,
148 | 'logo' => '',
149 | 'logo_url' => 'http://wwww.igetui.com/logo.png'
150 | ];
151 |
152 | Getui::pushToApp('notification', $data);
153 |
154 | ##### 3-3 全量推送-透传-全量
155 | $data = [
156 | 'transmission_type' => 2,
157 | 'content' => '透传内容-全量6'
158 | ];
159 | $res = Getui::pushToApp('transmission', $data);
160 |
161 | ##### 3-4 全量推送-透传模板-多推
162 | $data = [
163 | 'network_type' => 0,
164 | 'transmission_type' => 2,
165 | 'client_id_list' => [
166 | 'c3024643a24c11bd3762d437c9103a42'
167 | ],
168 | 'content' => '透传内容-多推1'
169 | ];
170 | Getui::pushToList('transmission', $data);
171 |
172 | #### 4 自定义消息
173 | ##### 4-1 全量推送-自定义消息-透传模板
174 |
175 | // 自定义数据
176 | $content = '自定义消息文本1243';
177 | $custom = [
178 | 'keyId' => 1,
179 | 'keyType' => 111199,
180 | 'msg' => $content
181 | ];
182 | $data = [
183 | 'title' => '自定义消息标题-122',
184 | 'transmission_type' => 2,
185 | 'function' => 'json_encode',
186 | 'content' => $content,
187 | 'custom_data' => $custom,
188 | 'custom_fields' => [
189 | 'keyId', 'keyType'
190 | ],
191 | 'speed' => 100, // 可选参数:定速推送 若设置100,则个推控制下发速度在100条/秒左右 默认无表示不定速.
192 | ];
193 |
194 | Getui::pushToApp('transmission', $data);
195 |
196 | ##### 4-2 单推-自定义消息-透传模板
197 | // 自定义数据
198 | $content = [
199 | 'keyId' => 1,
200 | 'keyType' => 111199
201 | ];
202 | $data = [
203 | 'title' => '自定义消息iOS',
204 | 'network_type' => 0,
205 | 'transmission_type' => 2,
206 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
207 | 'content' => json_encode($content) // 自定义数据加密 接收端需要按照同样方式解密
208 | ];
209 | Getui::pushToSingle('transmission', $data);
210 |
211 | ##### 4-3 多推-自定义消息-透传模板
212 | $data = [
213 | 'title' => '自定义消息iOS',
214 | 'network_type' => 0,
215 | 'transmission_type' => 2,
216 | 'client_id_list' => [
217 | 'c3024643a24c11bd3762d437c9103a42'
218 | ],
219 | 'content' => json_encode($content) // 自定义数据加密 接收端需要按照同样方式解密
220 | ];
221 | Getui::pushToList('transmission', $data);
222 |
223 |
224 | ### 后续功能待添加
225 | #### 1 消息撤回
226 | #### 2 通知消息模板下载
227 | #### 3 实时设置配置信息等
228 |
229 |
230 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "lysice/laravel-getui",
3 | "description": "A getui package for laravel or lumen.",
4 | "type": "library",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "lysice",
9 | "email": "snowist@126.com"
10 | }
11 | ],
12 | "autoload": {
13 | "psr-4": {"Lysice\\Getui\\": "src"}
14 | },
15 | "autoload-dev": {
16 | "psr-4": {"Lysice\\Getui\\": "src"}
17 | },
18 | "minimum-stability": "dev",
19 | "require": {}
20 | }
21 |
--------------------------------------------------------------------------------
/getui/IGt.Batch.php:
--------------------------------------------------------------------------------
1 | APPKEY = $appkey;
23 | $this->push = $push;
24 | $this->batchId = uniqid();
25 |
26 | }
27 |
28 | public function getBatchId()
29 | {
30 | return $this->batchId;
31 | }
32 |
33 | public function add($message, $target)
34 | {
35 | if ($this->seqId >= 5000) {
36 | throw new Exception("Can not add over 5000 message once! Please call submit() first.");
37 | } else {
38 | $this->seqId += 1;
39 | $innerMsg = new SingleBatchItem();
40 | $innerMsg->set_seqId($this->seqId);
41 | $innerMsg->set_data($this->createSingleJson($message, $target));
42 | array_push($this->innerMsgList, $innerMsg);
43 | }
44 | return $this->seqId . "";
45 | }
46 |
47 | public function createSingleJson($message, $target)
48 | {
49 | $params = $this->push->getSingleMessagePostData($message,$target);
50 | return json_encode($params);
51 | }
52 |
53 | public function submit()
54 | {
55 | $requestId = uniqid();
56 | $data = array();
57 | $data["appkey"]=$this->APPKEY;
58 | $data["serialize"] = "pb";
59 | $data["async"] = GTConfig::isPushSingleBatchAsync();
60 | $data["action"] = "pushMessageToSingleBatchAction";
61 | $data['requestId'] = $requestId;
62 | $singleBatchRequest = new SingleBatchRequest();
63 | $singleBatchRequest->set_batchId($this->batchId);
64 | foreach ($this->innerMsgList as $index => $innerMsg) {
65 | $singleBatchRequest->add_batchItem();
66 | $singleBatchRequest->set_batchItem($index, $innerMsg);
67 | }
68 | $data["singleDatas"] = base64_encode($singleBatchRequest->SerializeToString());
69 | $this->seqId = 0;
70 | $this->innerMsgList = array();
71 | $this->lastPostData = $data;
72 | $result = $this->push->httpPostJSON(null, $data, true);
73 | return $result;
74 | }
75 |
76 | public function retry()
77 | {
78 | $result = $this->push->httpPostJSON(null, $this->lastPostData, true);
79 | return $result;
80 | }
81 |
82 | public function setApiUrl($apiUrl) {
83 | }
84 | }
--------------------------------------------------------------------------------
/getui/demo.php:
--------------------------------------------------------------------------------
1 | setBlackThirdparty(Thirdparty::HW,Thirdparty::MZ);
75 | }
76 | //getPersonaTagsDemo1();
77 | function getPersonaTagsDemo() {
78 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
79 | $ret = $igt->getPersonaTags(APPID);
80 | var_dump($ret);
81 | }
82 | function getUserCountByTagsDemo() {
83 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
84 | $tagList = array("金在中","龙卷风");
85 | $ret = $igt->getUserCountByTags(APPID, $tagList);
86 | var_dump($ret);
87 | }
88 |
89 | function getScheduleTaskDemo(){
90 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
91 | $ret = $igt->getScheduleTask(TASKID,APPID);
92 | var_dump($ret);
93 | }
94 | function delScheduleTaskDemo(){
95 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
96 | $ret = $igt->delScheduleTask(TASKID,APPID);
97 | var_dump($ret);
98 | }
99 | function getPushResultByGroupNameDemo(){
100 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
101 | $ret = $igt->getPushResultByGroupName(APPID,"11");
102 | json_encode($ret);
103 | }
104 | //getLast24HoursOnlineUserStatisticsDemo();
105 | function getLast24HoursOnlineUserStatisticsDemo(){
106 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
107 | $ret = $igt->getLast24HoursOnlineUserStatistics("appid");
108 | var_dump($ret);
109 | }
110 | function restoreCidListFromBlkDemo(){
111 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
112 | $cidList=array("cid","");
113 | $ret = $igt->restoreCidListFromBlk(APPID,$cidList);
114 | var_dump($ret);
115 | }
116 | function addCidListToBlkDemo(){
117 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
118 | $cidList=array("cid","");
119 | $ret = $igt->addCidListToBlk(APPID,$cidList);
120 | var_dump($ret);
121 | }
122 | function setBadgeForCIDDemo(){
123 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
124 | $cidList=array("cid","");
125 | $ret = $igt->setBadgeForCID(Badge,APPID,$cidList);
126 | var_dump($ret);
127 | }
128 | function setBadgeForDeviceTokenDemo(){
129 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
130 | $cidList=array("cid","");
131 | $ret = $igt->setBadgeForDeviceToken(Badge,APPID,$cidList);
132 | var_dump($ret);
133 | }
134 | function pushTagMessageRetryDemo(){
135 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
136 | $template = IGtLinkTemplateDemo();
137 | //个推信息体
138 | //基于应用消息体
139 | $message = new IGtTagMessage();
140 | $message->set_isOffline(true);
141 | $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
142 | $message->set_data($template);
143 |
144 | $appIdList=array(APPID);
145 |
146 | $message->set_tag("123");
147 | $message->set_appIdList($appIdList);
148 | $ret = $igt->pushTagMessageRetry($message);
149 | var_dump($ret);
150 | }
151 | //bindCidPnDemo();
152 | function bindCidPnDemo(){
153 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
154 | $params = array();
155 | $params[CID] = md5(PN);
156 | $params["cid"] = PN;
157 | $ret = $igt->bindCidPn(appId,$params);
158 | var_dump($ret);
159 | }
160 | //unbindCidPnDemo();
161 | function unbindCidPnDemo(){
162 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
163 | $cids=array("cid","");
164 | $ret = $igt->unbindCidPn(APPID,$cids);
165 | var_dump($ret);
166 | }
167 | function queryCidPnDemo(){
168 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
169 | $cidList=array(CID);
170 | $ret = $igt->queryCidPn(APPID,$cidList);
171 | var_dump($ret);
172 | }
173 | function stopSendSmsDemo(){
174 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
175 | $ret = $igt->stopSendSms(APPID,TASKID);
176 | var_dump($ret);
177 | }
178 |
179 | function getPushMessageResultDemo(){
180 |
181 | // putenv("gexin_default_domainurl=http://183.129.161.174:8006/apiex.htm");
182 |
183 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
184 |
185 | // $ret = $igt->getPushResult("OSA-0522_QZ7nHpBlxF6vrxGaLb1FA3");
186 | // var_dump($ret);
187 |
188 | // $ret = $igt->queryAppUserDataByDate(APPID,"20140807");
189 | // var_dump($ret);
190 |
191 | $ret = $igt->queryAppPushDataByDate(APPID,"20190807");
192 | var_dump($ret);
193 | }
194 |
195 | //用户状态查询
196 | //getUserStatus();
197 | function getUserStatus() {
198 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
199 | $rep = $igt->getClientIdStatus(APPID,CID);
200 | var_dump($rep);
201 | echo ("
");
202 | }
203 |
204 | //推送任务停止
205 | function stoptask(){
206 |
207 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
208 | $igt->stop("taskid");
209 | }
210 |
211 | //通过服务端设置ClientId的标签
212 | function setTag(){
213 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
214 | $tagList = array('','中文','English');
215 | $rep = $igt->setClientTag(APPID,CID,$tagList);
216 | var_dump($rep);
217 | echo ("
");
218 | }
219 |
220 | function getUserTags() {
221 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
222 | $rep = $igt->getUserTags(APPID,CID);
223 | //$rep.connect();
224 | var_dump($rep);
225 | echo ("
");
226 | }
227 |
228 | //try {
229 | // pushMessageToSingleToSMS();
230 | //} catch (Exception $e) {
231 | // echo 1222;
232 | // echo $e->getMessage();
233 | //}
234 | //setSmsInfo接口
235 | //pushMessageToSingleToSMS();
236 | function pushMessageToSingleToSMS(){
237 |
238 | try {
239 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
240 | $template = new IGtTransmissionTemplate();
241 | $template->set_appId(APPID);
242 | $template->set_appkey(APPKEY);
243 | $template->set_transmissionType(2);
244 | $template->set_transmissionContent("123123");
245 | $template->setBlackThirdparty(Thirdparty::FCM,Thirdparty::XM);
246 | $notify = new IGtNotify();
247 | $notify->set_title("title");
248 | $notify->set_content("content");
249 | $notify->set_notifyId(123456789);
250 | $notify->set_type(NotifyInfo_Type::_intent);
251 | $notify->set_url("http://www.baidu.com");
252 | $notify->set_payload("通知内容中携带的透传内容");
253 | //设置华为角标
254 | $notify->addHWExtKV("badgeAddNum","\"1\"");
255 | $notify->addHWExtKV("badgeClass","\"activity\"");
256 | //设置华为图标
257 | $notify->addHWExtKV("icon","http://www.baidu.com");
258 | $notify->set_intent("intent:#Intent;action=com.demo.getui;component=com.demo.getui/activity;S.key1=value1;end");
259 | // $notify->set_intent("intent:#Intent;package=com.pp.yl;component=com.pp.yl/com.getui.demo.MainActivity;i.parm1=12;f.parm2=13.5;b.parm3=3;l.parm4=12345678954;s.parm5=10;S.parm6=string%20%E7%B1%BB%E5%9E%8B;S.parm7=body%20%3C%20%3E%20%3D%20*%20%3F%20!%20%23;B.parm8=true;d.parm9=13.501256;with;end");
260 | $template->set3rdNotifyInfo($notify);
261 | $smsMessage = new SmsMessage();// $smsContent = array();
262 | // $smsContent["url"] = "http://www.baidu.com/getui";
263 | $smsMessage->setPayload("1234");
264 | $smsMessage->setUrl("http://www/getui");
265 | $smsMessage->setSmsTemplateId("a278f716b5fe4434b4f3bf4e46ca9d36");
266 | $smsMessage->setOfflineSendtime(1000);
267 | $smsMessage->setIsApplink(true);// $smsMessage->smsContent($smsContent);
268 | $template->setSmsInfo($smsMessage);
269 | $message = new IGtSingleMessage();
270 | $message->set_isOffline(true);
271 | $message->set_offlineExpireTime(60 * 60 * 1000);
272 | $message->set_data($template);
273 | $target = new IGtTarget();
274 | $target->set_appId(APPID);
275 | $target->set_clientId(CID);
276 | echo 2;
277 | } catch (Exception $e) {
278 | echo $e->getTraceAsString();
279 | echo $e->getMessage();
280 | }
281 | try {
282 | for ($i = 0; $i < 1; $i++) {
283 | $ret = $igt->pushMessageToSingle($message, $target, "121231233123");
284 | var_dump($ret);
285 | }
286 | }catch (RequestException $e){
287 | $requstId = $e->getRequestId();
288 | $ret = $igt->pushMessageToSingle($message,$target,$requstId);
289 | var_dump($ret);
290 | }
291 | }
292 | //服务端推送接口,支持三个接口推送
293 | //1.PushMessageToSingle接口:支持对单个用户进行推送
294 | //2.PushMessageToList接口:支持对多个用户进行推送,建议为50个用户
295 | //3.pushMessageToApp接口:对单个应用下的所有用户进行推送,可根据省份,标签,机型过滤推送
296 | //
297 | //单推接口案例
298 | function pushMessageToSingle(){
299 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
300 |
301 | //消息模版:
302 | // 1.TransmissionTemplate:透传功能模板
303 | // 2.LinkTemplate:通知打开链接功能模板
304 | // 3.NotificationTemplate:通知透传功能模板
305 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板
306 |
307 | // $template = IGtNotyPopLoadTemplateDemo();
308 | // $template = IGtLinkTemplateDemo();
309 | $template = IGtNotificationTemplateDemo();
310 | // $template = IGtTransmissionTemplateDemo();
311 | // $template = IGtTransmissionVOIPTemplateDemo();
312 | // $template = SmsDemo();
313 | //个推信息体
314 | $message = new IGtSingleMessage();
315 |
316 | $message->set_isOffline(true);//是否离线
317 | $message->set_offlineExpireTime(3600*12*1000);//离线时间
318 | $message->set_data($template);//设置推送消息类型
319 | // $message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
320 | //接收方
321 | $target = new IGtTarget();
322 | $target->set_appId(APPID);
323 | $target->set_clientId(CID);
324 | // $target->set_alias(Alias);
325 |
326 |
327 | try {
328 | $rep = $igt->pushMessageToSingle($message, $target);
329 | var_dump($rep);
330 | echo ("
");
331 |
332 | }catch(RequestException $e){
333 | $requstId =$e->getRequestId();
334 | $rep = $igt->pushMessageToSingle($message, $target,$requstId);
335 | var_dump($rep);
336 | echo ("
");
337 | }
338 |
339 | }
340 |
341 |
342 | function pushMessageToSingleBatch()
343 | {
344 | putenv("gexin_pushSingleBatch_needAsync=false");
345 |
346 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
347 | $batch = new IGtBatch(APPKEY, $igt);
348 | $batch->setApiUrl(HOST);
349 | //$igt->connect();
350 | //消息模版:
351 | // 1.TransmissionTemplate:透传功能模板
352 | // 2.LinkTemplate:通知打开链接功能模板
353 | // 3.NotificationTemplate:通知透传功能模板
354 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板
355 |
356 | //$template = IGtNotyPopLoadTemplateDemo();
357 | $templateLink = IGtLinkTemplateDemo();
358 | $templateNoti = IGtNotificationTemplateDemo();
359 | //$template = IGtTransmissionTemplateDemo();
360 |
361 | //个推信息体
362 | $messageLink = new IGtSingleMessage();
363 | $messageLink->set_isOffline(true);//是否离线
364 | $messageLink->set_offlineExpireTime(12 * 1000 * 3600);//离线时间
365 | $messageLink->set_data($templateLink);//设置推送消息类型
366 | //$messageLink->set_PushNetWorkType(1);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
367 |
368 | $targetLink = new IGtTarget();
369 | $targetLink->set_appId(APPID);
370 | $targetLink->set_clientId(CID1);
371 | $batch->add($messageLink, $targetLink);
372 |
373 | //个推信息体
374 | $messageNoti = new IGtSingleMessage();
375 | $messageNoti->set_isOffline(true);//是否离线
376 | $messageNoti->set_offlineExpireTime(12 * 1000 * 3600);//离线时间
377 | $messageNoti->set_data($templateNoti);//设置推送消息类型
378 | //$messageNoti->set_PushNetWorkType(1);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
379 |
380 | $targetNoti = new IGtTarget();
381 | $targetNoti->set_appId(APPID);
382 | $targetNoti->set_clientId(CID2);
383 | $batch->add($messageNoti, $targetNoti);
384 | try {
385 |
386 | $rep = $batch->submit();
387 | var_dump($rep);
388 | echo("
");
389 | }catch(Exception $e){
390 | $rep=$batch->retry();
391 | var_dump($rep);
392 | echo ("
");
393 | }
394 | }
395 |
396 | //pushMessageToList();
397 | //多推接口案例
398 | function pushMessageToList()
399 | {
400 | putenv("gexin_pushList_needDetails=true");
401 | putenv("gexin_pushList_needAsync=true");
402 |
403 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
404 | //消息模版:
405 | // 1.TransmissionTemplate:透传功能模板
406 | // 2.LinkTemplate:通知打开链接功能模板
407 | // 3.NotificationTemplate:通知透传功能模板
408 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板
409 |
410 |
411 | //$template = IGtNotyPopLoadTemplateDemo();
412 | //$template = IGtLinkTemplateDemo();
413 | //$template = IGtNotificationTemplateDemo();
414 | $template = IGtTransmissionTemplateDemo();
415 | //个推信息体
416 | $message = new IGtListMessage();
417 | $message->set_isOffline(true);//是否离线
418 | $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间
419 | $message->set_data($template);//设置推送消息类型
420 | // $message->set_PushNetWorkType(1); //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
421 | // $contentId = $igt->getContentId($message);
422 | $contentId = $igt->getContentId($message,"toList任务别名功能"); //根据TaskId设置组名,支持下划线,中文,英文,数字
423 |
424 | //接收方1
425 | $target1 = new IGtTarget();
426 | $target1->set_appId(APPID);
427 | $target1->set_clientId(CID);
428 | // $target1->set_alias(Alias);
429 |
430 | $targetList[] = $target1;
431 |
432 | $rep = $igt->pushMessageToList($contentId, $targetList);
433 |
434 | var_dump($rep);
435 |
436 | echo ("
");
437 |
438 | }
439 |
440 | //群推接口案例
441 | function pushMessageToApp(){
442 |
443 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
444 |
445 | // $template = IGtLinkTemplateDemo();
446 | $template = IGtNotificationTemplateDemo();
447 | //个推信息体
448 | //基于应用消息体
449 | $message = new IGtAppMessage();
450 | $message->set_isOffline(true);
451 | $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
452 | $message->set_data($template);
453 | $appIdList=array(APPID);
454 | $phoneTypeList=array('ANDROID');
455 | $provinceList=array('浙江');
456 | $tagList=array('haha');
457 | $age = array("0000", "0010");
458 | //
459 | //
460 | $cdt = new AppConditions();
461 | $cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList);
462 | $cdt->addCondition(AppConditions::REGION, $provinceList);
463 | $cdt->addCondition(AppConditions::TAG, $tagList);
464 | $cdt->addCondition("age", $age);
465 |
466 | $message->set_appIdList($appIdList);
467 | // $message->set_conditions($cdt);
468 | $rep = $igt->pushMessageToApp($message);
469 |
470 | var_dump($rep);
471 | echo ("
");
472 | }
473 |
474 | //所有推送接口均支持四个消息模板,依次为通知弹框下载模板,通知链接模板,通知透传模板,透传模板
475 | //注:IOS离线推送需通过APN进行转发,需填写pushInfo字段,目前仅不支持通知弹框下载功能
476 |
477 | function IGtNotyPopLoadTemplateDemo(){
478 | $template = new IGtNotyPopLoadTemplate();
479 |
480 | $template->set_notifyId(12345678);
481 | $template ->set_appId(APPID);//应用appid
482 | $template ->set_appkey(APPKEY);//应用appkey
483 | //通知栏
484 | $template ->set_notyTitle("个推");//通知栏标题
485 | $template ->set_notyContent("个推最新版点击下载");//通知栏内容
486 | $template ->set_notyIcon("");//通知栏logo
487 | $template ->set_isBelled(true);//是否响铃
488 | $template ->set_isVibrationed(true);//是否震动
489 | $template ->set_isCleared(true);//通知栏是否可清除
490 | //弹框
491 | $template ->set_popTitle("弹框标题");//弹框标题
492 | $template ->set_popContent("弹框内容");//弹框内容
493 | $template ->set_popImage("");//弹框图片
494 | $template ->set_popButton1("下载");//左键
495 | $template ->set_popButton2("取消");//右键
496 | //下载
497 | $template ->set_loadIcon("");//弹框图片
498 | $template ->set_loadTitle("地震速报下载");
499 | $template ->set_loadUrl("http://url");
500 | $template ->set_isAutoInstall(false);
501 | $template ->set_isActived(true);
502 | $template->set_channel("set_channel");
503 | $template->set_channelName("set_channelName");
504 | $template->set_channelLevel(3);
505 | //$template->set_notifyStyle(0);
506 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
507 |
508 | return $template;
509 | }
510 |
511 | function IGtLinkTemplateDemo(){
512 | $template = new IGtLinkTemplate();
513 | $template ->set_appId(APPID);//应用appid
514 | $template ->set_appkey(APPKEY);//应用appkey
515 | $template ->set_title("请输入通知标题");//通知栏标题
516 | $template ->set_text("请输入通知内容");//通知栏内容
517 | $template ->set_logo("");//通知栏logo
518 | $template ->set_isRing(true);//是否响铃
519 | $template ->set_isVibrate(true);//是否震动
520 | $template ->set_isClearable(true);//通知栏是否可清除
521 | $template ->set_url("http://www.igetui.com/");//打开连接地址
522 | $template->set_channel("set_channel");
523 | $template->set_channelName("set_channelName");
524 | $template->set_channelLevel(3);
525 | // $template->set_notifyId(123456789);
526 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
527 | return $template;
528 | }
529 |
530 | function IGtNotificationTemplateDemo(){
531 | $template = new IGtNotificationTemplate();
532 | $template->set_appId(APPID);//应用appid
533 | $template->set_appkey(APPKEY);//应用appkey
534 | $template->set_transmissionType(1);//透传消息类型
535 | $template->set_transmissionContent("测试离线");//透传内容
536 | $template->set_title("请输入通知栏\p{1f631}\p");//通知栏标题
537 | $template->set_text("请输入通知");//通知栏内容
538 | // $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo
539 | // $template->set_isRing(true);//是否响铃
540 | // $template->set_isVibrate(true);//是否震动
541 | $template->set_isClearable(true);//通知栏是否可清除
542 | // $template->set_notifyId(123456789);
543 | // $template->set_channel("set_channel");
544 | // $template->set_channelName("set_channelName");
545 | // $template->set_channelLevel(3);
546 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
547 | return $template;
548 | }
549 |
550 | //try {
551 | // IGtTransmissionTemplateDemo();
552 | //} catch (Exception $e) {
553 | // echo $e->getMessage();
554 | //}
555 | function IGtTransmissionTemplateDemo(){
556 | $template = new IGtTransmissionTemplate();
557 | $template->set_appId(APPID);//应用appid
558 | $template->set_appkey(APPKEY);//应用appkey
559 | $template->set_transmissionType(1);//透传消息类型
560 | $template->set_transmissionContent("测试离线ddd");//透传内容
561 | // $template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
562 | //APN简单推送
563 | // $template = new IGtAPNTemplate();
564 | $apn = new IGtAPNPayload();
565 | $alertmsg=new SimpleAlertMsg();
566 | $alertmsg->alertMsg="";
567 | $apn->alertMsg=$alertmsg;
568 | $apn->badge=2;
569 | $apn->sound="";
570 | $apn->add_customMsg("payload","payload");
571 | $apn->contentAvailable=1;
572 | $apn->category="ACTIONABLE";
573 | // $template->set_apnInfo($apn);
574 | // $message = new IGtSingleMessage();
575 |
576 | //第三方厂商推送透传消息带通知处理
577 |
578 | $notify = new IGtNotify();
579 | $notify -> set_payload("{}");
580 | $notify -> set_title("透传通知标题");
581 | $notify -> set_content("透传通知内容");
582 | $notify->set_type(NotifyInfo_Type::_payload);
583 | // $message1 = new cTest();
584 | // $message1->set_a("aaaaa");
585 | //
586 | // $notify->addXMExtKV("mzy-xm-k",$message1);
587 | // $notify->addHWExtKV("mzy-hw-k",$message1);
588 | // $notify->addFCMExtKV("mzy-fcm-k",$message1);
589 | // $notify->addOPExtKV("mzy-op-k",$message1);
590 | $template -> set3rdNotifyInfo($notify);
591 |
592 | //APN高级推送
593 | $apn = new IGtAPNPayload();
594 | $alertmsg=new DictionaryAlertMsg();
595 | $alertmsg->body="body";
596 | $alertmsg->actionLocKey="ActionLockey";
597 | $alertmsg->locKey="LocKey";
598 | $alertmsg->locArgs=array("locargs");
599 | $alertmsg->launchImage="launchimage";
600 | // IOS8.2 支持
601 | $alertmsg->title="Title";
602 | $alertmsg->titleLocKey="TitleLocKey";
603 | $alertmsg->titleLocArgs=array("TitleLocArg");
604 |
605 | $alertmsg->subtitle = "subtitle";
606 |
607 | $apn->alertMsg=$alertmsg;
608 | $apn->badge=7;
609 | $apn->sound="";
610 | $apn->add_customMsg("payload","payload");
611 | $apn->voicePlayType = 1;
612 | $apn->contentAvailable=1;
613 | $apn->category="ACTIONABLE";
614 | //IOS多媒体消息处理
615 | $media = new IGtMultiMedia();
616 | $media -> set_url("http://url");
617 | $media -> set_onlywifi(false);
618 | $media -> set_type(MediaType::pic);
619 |
620 | $medias = array();
621 | $medias[] = $media;
622 | //$apn->set_multiMedias($medias);
623 |
624 | // $template->set_pushInfo();
625 | $template->set_apnInfo($apn);
626 |
627 | //PushApn老方式传参
628 | // $template = new IGtAPNTemplate();
629 | // $template->set_pushInfo("", 10, "", "com.gexin.ios.silence", "", "", "", "");
630 | return $template;
631 | }
632 |
633 | //多标签推送接口案例
634 | function pushMessageByTag(){
635 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
636 | $template = IGtLinkTemplateDemo();
637 | //个推信息体
638 | //基于应用消息体
639 | $message = new IGtTagMessage();
640 | $message->set_isOffline(true);
641 | $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
642 | $message->set_data($template);
643 |
644 | $appIdList=array(APPID);
645 |
646 | $message->set_tag("123");
647 | $message->set_appIdList($appIdList);
648 |
649 | $rep = $igt->pushTagMessage($message);
650 |
651 | var_dump($rep);
652 | echo ("
");
653 | }
654 |
655 | // 透传消息模板
656 | function IGtTransmissionTemplateFunction(){
657 | $template = new IGtTransmissionTemplate();
658 | $template->set_appId('appid');//应用appid
659 | $template->set_appkey('appkey');//应用appkey
660 | $template->set_transmissionType(1);//透传消息类型
661 | $template->set_transmissionContent('12345677');//透传内容
662 |
663 | return $template;
664 | }
665 | // 打开应用内页面
666 | function IGtStartActivityTemplateDemo(){
667 |
668 | try {
669 | $template = new IGtStartActivityTemplate();
670 | } catch (Exception $e) {
671 | echo $e->getMessage();
672 | }
673 | echo 21;
674 | $template->set_appId(APPID);//应用appid
675 | $template->set_appkey(APPKEY);//应用appkey
676 | $template->set_intent("");
677 | $template->set_title("个推");//通知栏标题
678 | $template->set_text("个推最新版点击下载");//通知栏内容
679 | $template->set_logo("");//通知栏logo
680 | $template->set_logoURL("http://*");
681 | $template->set_isRing(true);//是否响铃
682 | $template->set_isVibrate(true);//是否震动
683 | $template->set_isClearable(true);//通知栏是否可清除
684 | $template->set_duration("2019-10-14 08:00:00","2019-10-14 09:00:00");
685 | $smsMessage = new SmsMessage();//设置短信通知
686 | $smsMessage->setPayload("1234");
687 | $smsMessage->setUrl("http://www/getui");
688 | $smsMessage->setSmsTemplateId("123456789");
689 | $smsMessage->setOfflineSendtime(1000);
690 | $smsMessage->setIsApplink(true);
691 | $template->setSmsInfo($smsMessage);
692 | $template->set_notifyId(123456543);
693 | return $template;
694 | }
695 | // 撤回
696 | function getRevokeTemplateDemo(){
697 | $revoke = new IGtRevokeTemplate();
698 | $revoke->set_appId("appid");
699 | $revoke->set_appkey("appkey");
700 | $revoke->set_oldTaskId("taskId");
701 | $revoke->set_force(false);
702 | return $revoke;
703 | }
704 |
705 | try {
706 | try {
707 |
708 | $igt = new IGeTui(null, APPKEY, MASTERSECRET);
709 | } catch (Exception $e) {
710 | echo $e->getMessage();
711 | }
712 | for ($i = 0; $i < 1; $i++) {
713 | echo "------------------fasturl = ". $igt->host."\n";
714 | pushMessageToSingleForTemplate($igt);
715 | sleep(3);
716 | }
717 | } catch (Exception $e) {
718 | echo $e->getMessage();
719 | }
720 | //setSmsInfo接口
721 | function pushMessageToSingleForTemplate($igt){
722 |
723 | // $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
724 | // $template = IGtNotyPopLoadTemplateDemo();
725 | $template = IGtNotificationTemplateDemo();
726 | // $template = IGtLinkTemplateDemo();
727 | // $template = IGtStartActivityTemplateDemo();
728 | // $template=IGtTransmissionTemplateDemo();
729 | // echo 'begin';
730 |
731 | //APN简单推送
732 | // $apn = new IGtAPNPayload();
733 | // $alertmsg=new DictionaryAlertMsg();
734 | // $alertmsg->title = "title";
735 | // $alertmsg->set_summaryArg("set_summaryArg");
736 | // $alertmsg->set_summaryArgCount(4);
737 |
738 | // $apn->alertMsg=$alertmsg;
739 | // $apn->badge=2;
740 | // $apn->sound="";
741 | // $apn->add_customMsg("payload","payload");
742 | // $apn->contentAvailable=1;
743 | // $apn->category="ACTIONABLE";
744 | // $apn->set_threadId("set_threadId");
745 | $sound_d = new Sound();
746 | $sound_d->set_name("set_name");
747 | $sound_d->set_critical(1);
748 | // $sound_d->set_volume(0.5);
749 | // $apn->set_sound_d($sound_d);
750 | // $template->set_apnInfo($apn);
751 | echo 'begin';
752 |
753 | $message = new IGtSingleMessage();
754 | $message->set_isOffline(true);
755 | $message->set_offlineExpireTime(60 * 60 * 1000);
756 | $message->set_data($template);
757 | $message->set_pushNetWorkType(0);
758 | $target = new IGtTarget();
759 | $target->set_appId(APPID);
760 | $target->set_clientId(CID);
761 | try {
762 | for ($i = 0; $i < 1; $i++) {
763 | echo 'begin';
764 | $ret = $igt->pushMessageToSingle($message, $target, "121231233123");
765 | var_dump($ret);
766 | }
767 | }catch (Exception $e){
768 | echo $e->getMessage();
769 | // $requstId = $e->getRequestId();
770 | // $ret = $igt->pushMessageToSingle($message,$target,$requstId);
771 | // var_dump($ret);
772 | }
773 | }
774 | ?>
775 |
776 |
--------------------------------------------------------------------------------
/getui/exception/GtException.php:
--------------------------------------------------------------------------------
1 | requestId = $param[0];
16 | }
17 | }
18 |
19 | public function getRequestId()
20 | {
21 | return $this->requestId;
22 | }
23 | }
--------------------------------------------------------------------------------
/getui/exception/RequestException.php:
--------------------------------------------------------------------------------
1 | requestId = $requestId;
16 | }
17 | public function getRequestId()
18 | {
19 | return $this->requestId;
20 | }
21 | }
--------------------------------------------------------------------------------
/getui/igetui/IGt.APNPayload.php:
--------------------------------------------------------------------------------
1 | alertMsg != null) {
41 | $msg = $this->alertMsg->get_alertMsg();
42 | if($msg != null)
43 | {
44 | $apsMap["alert"] = $msg;
45 | }
46 | }
47 | if($this->autoBadge != null){
48 | $apsMap["autoBadge"] = $this->autoBadge;
49 | }elseif($this->badge >= 0) {
50 | $apsMap["badge"] = $this->badge;
51 | }
52 | if($this -> sound == null || $this->sound == '' )
53 | {
54 | $apsMap["sound"] = 'default';
55 | }elseif($this->sound != $this->APN_SOUND_SILENCE)
56 | {
57 | $apsMap["sound"] = $this->sound;
58 | }
59 |
60 | //IOS 12 的 sound_d 覆盖旧 的sound
61 | if (!empty($this->sound_d) && !empty($this->sound_d->get_asMap())){
62 | $apsMap["sound"] = $this->sound_d->get_asMap();
63 | }
64 |
65 | if (sizeof($apsMap) == 0) {
66 | throw new Exception("format error");
67 | }
68 | if ($this->contentAvailable > 0) {
69 | $apsMap["content-available"] = $this->contentAvailable;
70 | }
71 | if ($this->category != null && $this->category != "") {
72 | $apsMap["category"] = $this->category;
73 | }
74 |
75 | $map = array();
76 | if(count($this->customMsg) > 0){
77 | foreach ($this->customMsg as $key => $value) {
78 | $map[$key] = $value;
79 | }
80 | }
81 |
82 | if (!empty($this->threadId)){
83 | $apsMap["thread-id"] = $this->threadId;
84 | }
85 |
86 | $map["aps"] = $apsMap;
87 | if($this->apnsCollapseId != null){
88 | $map["apns-collapse-id"] = $this->apnsCollapseId;
89 | }
90 | if($this -> multiMedias != null && sizeof($this -> multiMedias) > 0) {
91 | $map["_grinfo_"] = $this->check_multiMedias();
92 | }
93 | if ($this->voicePlayType == 1){
94 | $map["_gvp_t_"] = 1;
95 | }elseif($this->voicePlayType == 2 && !empty($this->voicePlayMessage)){
96 | $map["_gvp_t_"] = 2;
97 | $map["_gvp_m_"] = $this->voicePlayMessage;
98 | }
99 | return json_encode($map);
100 | } catch (Exception $e) {
101 | throw new Exception("create apn payload error", -1, $e);
102 | }
103 | }
104 |
105 | public function add_customMsg($key, $value)
106 | {
107 | if ($key != null && $key != "" && $value != null) {
108 | $this->customMsg[$key] = $value;
109 | }
110 | }
111 |
112 | function check_multiMedias()
113 | {
114 | if(sizeof($this -> multiMedias) > 3) {
115 | throw new RuntimeException("MultiMedias size overlimit");
116 | }
117 |
118 | $needGeneRid = false;
119 | $rids = array();
120 | for($i = 0; $i < sizeof($this -> multiMedias); $i++) {
121 | $media = $this -> multiMedias[$i];
122 | if($media -> get_rid() == null) {
123 | $needGeneRid = true;
124 | } else {
125 | $rids[$media -> get_rid()] = 0;
126 | }
127 |
128 | if($media->get_type() == null || $media->get_url() == null) {
129 | throw new RuntimeException("MultiMedia resType and resUrl can't be null");
130 | }
131 | }
132 |
133 | if(sizeof($rids) != sizeof($this -> multiMedias)) {
134 | $needGeneRid = true;
135 | }
136 | if($needGeneRid) {
137 | for ($i = 0; $i < sizeof($this->multiMedias); $i++) {
138 | $this->multiMedias[$i] -> set_rid("grid-" . $i);
139 | }
140 | }
141 |
142 | return $this -> multiMedias;
143 | }
144 |
145 | function add_multiMedia($media) {
146 | $this->multiMedias[] = $media;
147 | return $this;
148 | }
149 |
150 | function set_multiMedias($medias) {
151 | $this->multiMedias = $medias;
152 | return $this;
153 | }
154 |
155 | function set_threadId($threadId){
156 | $this->threadId = $threadId;
157 | return $this;
158 | }
159 |
160 | function set_sound_d($sound){
161 | $this->sound_d = $sound;
162 | return $this;
163 | }
164 |
165 | function get_apnsCollapseId(){
166 | return $this->apnsCollapseId;
167 | }
168 |
169 | function set_apnsCollapseId($apnsCollapseId){
170 | $this->apnsCollapseId = $apnsCollapseId;
171 | }
172 | }
173 | interface ApnMsg
174 | {
175 | public function get_alertMsg();
176 | }
177 |
178 | class DictionaryAlertMsg implements ApnMsg{
179 |
180 | var $title;
181 | var $body;
182 | var $titleLocKey;
183 | var $titleLocArgs = array();
184 | var $actionLocKey;
185 | var $locKey;
186 | var $locArgs = array();
187 | var $launchImage;
188 | var $subtitle;
189 | var $subtitleLocKey;
190 | var $subtitleLocArgs;
191 | //IOS 12 新增
192 | var $summaryArg;
193 | //IOS 12 新增
194 | var $summaryArgCount = -1;
195 |
196 | public function get_alertMsg() {
197 |
198 | $alertMap = array();
199 |
200 | if ($this->title != null && $this->title != "") {
201 | $alertMap["title"] = $this->title;
202 | }
203 | if ($this->body != null && $this->body != "") {
204 | $alertMap["body"] = $this->body;
205 | }
206 | if ($this->titleLocKey != null && $this->titleLocKey != "") {
207 | $alertMap["title-loc-key"] = $this->titleLocKey;
208 | }
209 | if (sizeof($this->titleLocArgs) > 0) {
210 | $alertMap["title-loc-args"] = $this->titleLocArgs;
211 | }
212 | if ($this->actionLocKey != null && $this->actionLocKey) {
213 | $alertMap["action-loc-key"] = $this->actionLocKey;
214 | }
215 | if ($this->locKey != null && $this->locKey != "") {
216 | $alertMap["loc-key"] = $this->locKey;
217 | }
218 | if (sizeof($this->locArgs) > 0) {
219 | $alertMap["loc-args"] = $this->locArgs;
220 | }
221 | if ($this->launchImage != null && $this->launchImage != "") {
222 | $alertMap["launch-image"] = $this->launchImage;
223 | }
224 |
225 | if(count($alertMap) == 0)
226 | {
227 | return null;
228 | }
229 |
230 | if ($this->subtitle != null && $this->subtitle != "") {
231 | $alertMap["subtitle"] = $this->subtitle;
232 | }
233 | if (sizeof($this->subtitleLocArgs) > 0) {
234 | $alertMap["subtitle-loc-args"] = $this->subtitleLocArgs;
235 | }
236 | if ($this->subtitleLocKey != null && $this->subtitleLocKey != "") {
237 | $alertMap["subtitle-loc-key"] = $this->subtitleLocKey;
238 | }
239 | if (!empty($this->summaryArg)){
240 | $alertMap["summary-arg"] = $this->summaryArg;
241 | }
242 | if ($this->summaryArgCount != -1){
243 | $alertMap["summary-arg-count"] = $this->summaryArgCount;
244 | }
245 | return $alertMap;
246 | }
247 |
248 | function set_summaryArg($summaryArg){
249 | $this->summaryArg = $summaryArg;
250 | return $this;
251 | }
252 |
253 | function set_summaryArgCount($summaryArgCount){
254 | $this->summaryArgCount = $summaryArgCount;
255 | return $this;
256 | }
257 | }
258 |
259 | class SimpleAlertMsg implements ApnMsg{
260 | var $alertMsg;
261 |
262 | public function get_alertMsg() {
263 | return $this->alertMsg;
264 | }
265 | }
266 |
267 | class Sound{
268 | //取值范围0,1
269 | var $critical = -1;
270 | var $name;
271 | //取值范围0-1,一位小数,超过一位四舍五入
272 | var $volume = -1;
273 |
274 | function set_critical($critical)
275 | {
276 | $this->critical = $critical;
277 | }
278 |
279 | function set_name($name)
280 | {
281 | $this->name = $name;
282 | }
283 |
284 | function set_volume($volume)
285 | {
286 | if ($volume > 1 || $volume < 0){
287 | throw new Exception("volume of sound_d should between 0.0 and 1.0");
288 | }
289 | $this->volume = round($volume, 1);
290 | }
291 |
292 | function get_asMap()
293 | {
294 | $a = array();
295 | if (!empty($this->name)){
296 | $a["name"] = $this->name;
297 | }
298 | if ($this->critical != -1){
299 | $a["critical"] = $this->critical;
300 | }
301 | if ($this->volume != -1){
302 | $a["volume"] = $this->volume;
303 | }
304 | return $a;
305 | }
306 | }
307 | ?>
--------------------------------------------------------------------------------
/getui/igetui/IGt.AppMessage.php:
--------------------------------------------------------------------------------
1 | appIdList;
22 | }
23 |
24 | function set_appIdList($appIdList) {
25 | $this->appIdList = $appIdList;
26 | }
27 |
28 | /**
29 | * @deprecated deprecated since version 4.0.0.3
30 | */
31 | function get_phoneTypeList() {
32 | return $this->phoneTypeList;
33 | }
34 |
35 | /**
36 | * @deprecated deprecated since version 4.0.0.3
37 | */
38 | function set_phoneTypeList($phoneTypeList) {
39 | $this->phoneTypeList = $phoneTypeList;
40 | }
41 |
42 | /**
43 | * @deprecated deprecated since version 4.0.0.3
44 | */
45 | function get_provinceList() {
46 | return $this->provinceList;
47 | }
48 |
49 | /**
50 | * @deprecated deprecated since version 4.0.0.3
51 | */
52 | function set_provinceList($provinceList) {
53 | $this->provinceList = $provinceList;
54 | }
55 |
56 | /**
57 | * @deprecated deprecated since version 4.0.0.3
58 | */
59 | function get_tagList() {
60 | return $this->tagList;
61 | }
62 |
63 | /**
64 | * @deprecated deprecated since version 4.0.0.3
65 | */
66 | function set_tagList($tagList) {
67 | $this->tagList = $tagList;
68 | }
69 |
70 | public function get_conditions()
71 | {
72 | return $this->conditions;
73 | }
74 |
75 | /**
76 | * @return mixed
77 | */
78 | public function getPushTime()
79 | {
80 | return $this->pushTime;
81 | }
82 |
83 | /**
84 | * @param mixed $pushTime
85 | */
86 | public function setPushTime($pushTime)
87 | {
88 |
89 | $this->pushTime = $pushTime;
90 | }
91 |
92 |
93 | public function set_conditions($conditions)
94 | {
95 | $this->conditions = $conditions;
96 | }
97 |
98 | function get_speed()
99 | {
100 | return $this->speed;
101 | }
102 | function set_speed($speed)
103 | {
104 | $this->speed=$speed;
105 | }
106 | }
--------------------------------------------------------------------------------
/getui/igetui/IGt.ListMessage.php:
--------------------------------------------------------------------------------
1 | isOffline;
25 | }
26 | function set_isOffline($isOffline)
27 | {
28 | return $this->isOffline = $isOffline;
29 | }
30 | function get_offlineExpireTime()
31 | {
32 | return $this->offlineExpireTime;
33 | }
34 | function set_offlineExpireTime($offlineExpireTime)
35 | {
36 | return $this->offlineExpireTime = $offlineExpireTime;
37 | }
38 | function get_pushNetWorkType()
39 | {
40 | return $this->pushNetWorkType;
41 | }
42 | function set_pushNetWorkType($pushNetWorkType)
43 | {
44 | return $this->pushNetWorkType = $pushNetWorkType;
45 | }
46 | function get_data()
47 | {
48 | return $this->data;
49 | }
50 | function set_data($data)
51 | {
52 | return $this->data = $data;
53 | }
54 | }
--------------------------------------------------------------------------------
/getui/igetui/IGt.MultiMedia.php:
--------------------------------------------------------------------------------
1 | rid;
31 | }
32 |
33 | function set_rid($rid) {
34 | $this->rid = $rid;
35 | return $this;
36 | }
37 |
38 | function get_url() {
39 | return $this->url;
40 | }
41 |
42 | function set_url($url) {
43 | $this->url = $url;
44 | return$this;
45 | }
46 |
47 | function get_type() {
48 | return $this -> type;
49 | }
50 |
51 | function set_type($type) {
52 | $this -> type = $type;
53 | return $this;
54 | }
55 |
56 | function set_onlywifi($onlywifi) {
57 | $this -> onlywifi = $onlywifi ? 1:0;
58 | return $this;
59 | }
60 |
61 | function get_onlywifi() {
62 | return $this -> onlywifi;
63 | }
64 | }
65 |
66 | class MediaType {
67 | const __default = self::pic;
68 |
69 | const pic = 1;
70 | const audio = 2;
71 | const video = 3;
72 | }
73 |
--------------------------------------------------------------------------------
/getui/igetui/IGt.SingleMessage.php:
--------------------------------------------------------------------------------
1 | appIdList;
16 | }
17 |
18 | function set_appIdList($appIdList) {
19 | $this->appIdList = $appIdList;
20 | }
21 |
22 | function get_tag() {
23 | return $this->tag;
24 | }
25 |
26 | function set_tag($tag) {
27 | $this->tag = $tag;
28 | }
29 |
30 | function get_speed()
31 | {
32 | return $this->speed;
33 | }
34 | function set_speed($speed)
35 | {
36 | $this->speed=$speed;
37 | }
38 | }
--------------------------------------------------------------------------------
/getui/igetui/IGt.Target.php:
--------------------------------------------------------------------------------
1 | appId;
19 | }
20 | function set_appId($appId)
21 | {
22 | return $this->appId = $appId;
23 | }
24 | function get_clientId()
25 | {
26 | return $this->clientId;
27 | }
28 | function set_clientId($clientId)
29 | {
30 | return $this->clientId = $clientId;
31 | }
32 | function set_alias($alias)
33 | {
34 | return $this->alias = $alias;
35 | }
36 | function get_alias()
37 | {
38 | return $this->alias;
39 | }
40 | }
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.APNTemplate.php:
--------------------------------------------------------------------------------
1 | set_templateId($this->getTemplateId());
20 | $transparent->set_id('');
21 | $transparent->set_messageId('');
22 | $transparent->set_taskId('');
23 | $transparent->set_action('pushmessage');
24 | $transparent->set_pushInfo($this->get_pushInfo());
25 | $transparent->set_appId($this->appId);
26 | $transparent->set_appKey($this->appkey);
27 | if($this->smsInfo != null){
28 | $transparent->set_smsInfo($this->smsInfo);
29 | }
30 |
31 | $actionChainList = $this->getActionChain();
32 |
33 | foreach ($actionChainList as $index => $actionChain) {
34 | $transparent->add_actionChain();
35 | $transparent->set_actionChain($index, $actionChain);
36 | }
37 |
38 | $transparent->append_condition($this->get_durcondition());
39 |
40 | return $transparent->SerializeToString();
41 |
42 | //return $transparent->condition(0);
43 | }
44 |
45 | function getActionChain()
46 | {
47 | return $list = array();
48 | }
49 |
50 | function get_durcondition()
51 | {
52 | if ($this->duration == null || $this->duration == '')
53 | {
54 | return "";
55 | }
56 | return "duration=" . $this->duration;
57 | }
58 |
59 | function get_duration()
60 | {
61 | return $this->duration;
62 | }
63 |
64 | function set_duration($begin, $end)
65 |
66 | {
67 | date_default_timezone_set('asia/shanghai');
68 | /* //for test
69 | var_dump(date("Y-m-d H:i:s",strtotime($begin)));
70 | var_dump(date("Y-m-d H:i:s",strtotime($end)));
71 | */
72 | $ss = (string)strtotime($begin) * 1000;
73 | $e = (string)strtotime($end) * 1000;
74 | if ($ss <= 0 || $e <= 0)
75 | throw new Exception("DateFormat: yyyy-MM-dd HH:mm:ss");
76 | if ($ss > $e)
77 | throw new Exception("startTime should be smaller than endTime");
78 |
79 | $this->duration = $ss . "-" . $e;
80 |
81 | }
82 |
83 | function get_transmissionContent()
84 | {
85 | return null;
86 | }
87 |
88 | function get_pushType()
89 | {
90 | return null;
91 | }
92 |
93 | function get_actionChain()
94 | {
95 | return null;
96 | }
97 |
98 | function get_pushInfo()
99 | {
100 | if ($this->pushInfo == null) {
101 | $this->pushInfo = new PushInfo();
102 | $this->pushInfo->set_invalidAPN(true);
103 | $this->pushInfo->set_invalidMPN(true);
104 | }
105 |
106 | return $this->pushInfo;
107 | }
108 |
109 | function setSmsInfo($smsMessage){
110 |
111 | if($smsMessage == null){
112 | throw new RuntimeException("smsInfo cannot be empty");
113 | } else {
114 | $smsTemplateId = $smsMessage->getSmsTemplateId();
115 | $smsContent = $smsMessage->getSmsContent();
116 | $offlineSendtime = $smsMessage->getOfflineSendtime();
117 | $smsSendDuration = 0;
118 | if ($smsTemplateId != null || !empty($smsTemplateId)) {
119 | if ($offlineSendtime == null) {
120 | throw new RuntimeException("offlineSendtime cannot be empty");
121 | } else {
122 | $build = new SmsInfo();
123 | $build->set_smsChecked(false);
124 | $build->set_smsTemplateId($smsTemplateId);
125 | $build->set_offlineSendtime($offlineSendtime);
126 | if ($smsMessage->getisApplink()) {
127 |
128 | if ($smsContent['url'] != null) {
129 | throw new RuntimeException("SmsContent cann not contains key about url");
130 | }
131 | $smsContentEntry = new SmsContentEntry();
132 | $smsContentEntry->set_key("applinkIdentification");
133 | $smsContentEntry->set_value("1");
134 | $build->set_smsContent("applinkIdentification",$smsContentEntry);
135 | $payload = $smsMessage->getPayload();
136 |
137 | if ($payload != null && !empty($payload)) {
138 | $smsContentEntry = new SmsContentEntry();
139 | $smsContentEntry->set_key("url");
140 | $smsContentEntry->set_value($smsMessage->getUrl() . "?n=" . $payload . "&p=");
141 | $build->set_smsContent("url",$smsContentEntry);
142 | } else {
143 | $smsContentEntry = new SmsContentEntry();
144 | $smsContentEntry->set_key("url");
145 | $smsContentEntry->set_value($smsMessage->getUrl() . "?p=");
146 | $build->set_smsContent("url",$smsContentEntry);
147 | }
148 | }
149 | if ($smsContent != null) {
150 | foreach ($smsContent as $key => $value) {
151 | if ($key == null || empty($key) || $value == null) {
152 | throw new RuntimeException("smsContent entry cannot be null");
153 | } else {
154 | $smsContentEntry = new SmsContentEntry();
155 | $smsContentEntry->set_key($key);
156 | $smsContentEntry->set_value($value);
157 | $build->set_smsContent($key,$smsContentEntry);
158 | }
159 | }
160 | }
161 | if ($smsSendDuration != null) {
162 | $build->smsSendDuration($smsSendDuration);
163 | }
164 | $this->smsInfo = $build;
165 | }
166 | }
167 | else {
168 | throw new RuntimeException("smsTemplateId cannot be empty");
169 | }
170 |
171 | }
172 |
173 |
174 | }
175 | function set_pushInfo($actionLocKey, $badge, $message, $sound, $payload, $locKey, $locArgs, $launchImage, $contentAvailable = 0)
176 | {
177 | $apn = new IGtAPNPayload();
178 |
179 | $alertMsg = new DictionaryAlertMsg();
180 | if ($actionLocKey != null && $actionLocKey != '')
181 | {
182 | $alertMsg->actionLocKey = $actionLocKey;
183 | }
184 | if ($message != null && $message != '')
185 | {
186 | $alertMsg->body = $message;
187 | }
188 | if ($locKey != null && $locKey != '')
189 | {
190 | $alertMsg->locKey = $locKey;
191 | }
192 | if ($locArgs != null && $locArgs != '')
193 | {
194 | array_push($alertMsg->locArgs, $locArgs);
195 | }
196 |
197 | if ($launchImage != null && $launchImage != '')
198 | {
199 | $alertMsg->launchImage = $launchImage;
200 | }
201 | $apn->alertMsg = $alertMsg;
202 |
203 | if ($badge != null )
204 | {
205 | $apn->badge = $badge;
206 | }
207 | if ($sound != null && $sound != '')
208 | {
209 | $apn->sound = $sound;
210 | }
211 | if ($contentAvailable != null )
212 | {
213 | $apn->contentAvailable = $contentAvailable;
214 | }
215 | if ($payload != null && $payload != '')
216 | {
217 | $apn->add_customMsg("payload", $payload);
218 | }
219 | $this->set_apnInfo($apn);
220 | }
221 |
222 | function set_apnInfo($payload)
223 | {
224 | if ($payload == null) {
225 | return;
226 | }
227 | $payload = $payload->get_payload();
228 | if ($payload == null || $payload == "") {
229 | return;
230 | }
231 | $len = strlen($payload);
232 | if ($len > IGtAPNPayload::$PAYLOAD_MAX_BYTES) {
233 | throw new Exception("APN payload length overlength (" . $len . ">" . IGtAPNPayload::$PAYLOAD_MAX_BYTES . ")");
234 | }
235 | $pushInfo = $this->get_pushInfo();
236 | $pushInfo->set_apnJson($payload);
237 | $pushInfo->set_invalidAPN(false);
238 | }
239 |
240 | function set_appId($appId)
241 | {
242 | $this->appId = $appId;
243 | }
244 |
245 | function set_appkey($appkey)
246 | {
247 | $this->appkey = $appkey;
248 | }
249 |
250 | function abslength($str)
251 | {
252 | if (empty($str)) {
253 | return 0;
254 | }
255 | if (function_exists('mb_strlen')) {
256 | return mb_strlen($str, 'utf-8');
257 | } else {
258 | preg_match_all("/./u", $str, $ar);
259 | return count($ar[0]);
260 | }
261 | }
262 |
263 | function getTemplateId() {
264 | if($this instanceof IGtNotificationTemplate) {
265 | return 0;
266 | }
267 | if($this instanceof IGtLinkTemplate) {
268 | return 1;
269 | }
270 | if($this instanceof IGtNotyPopLoadTemplate) {
271 | return 2;
272 | }
273 | if($this instanceof IGtTransmissionTemplate) {
274 | return 4;
275 | }
276 | if($this instanceof IGtAPNTemplate) {
277 | return 5;
278 | }
279 |
280 | if($this instanceof IGtStartActivityTemplate) {
281 | return 7;
282 | }
283 | return -1;
284 | }
285 | function setBlackThirdparty(...$thirdparry){
286 | $numargs = count($thirdparry);
287 | if ($numargs > 0){
288 | $pushInfo = $this->get_pushInfo();
289 | for ($i = 0; $i < $numargs; $i++) {
290 | $pushInfo->set_blackThirdparty($i, $thirdparry[$i]);
291 | }
292 | }
293 | }
294 |
295 |
296 | }
297 |
298 | class Thirdparty
299 | {
300 | const HW = 'HW';
301 | const XM = 'XM';
302 | const VV = 'VV';
303 | const MZ = 'MZ';
304 | const FCM = 'FCM';
305 | const OP = 'OP';
306 | }
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.LinkTemplate.php:
--------------------------------------------------------------------------------
1 | set_actionId(1);
74 | $actionChain1->set_type(ActionChain_Type::refer);
75 | $actionChain1->set_next(10000);
76 |
77 | //通知
78 | $actionChain2 = new ActionChain();
79 | $actionChain2->set_actionId(10000);
80 | $actionChain2->set_type(ActionChain_Type::mmsinbox2);
81 | $actionChain2->set_stype("notification");
82 |
83 | $f_notifyId = new InnerFiled();
84 | $f_notifyId->set_key("notifyid");
85 | $f_notifyId->set_val(empty($this->notifyId)?"":$this->notifyId);
86 | $f_notifyId->set_type(InnerFiled_Type::str);
87 | $actionChain2->set_field(0, $f_notifyId);
88 |
89 | $f_text = new InnerFiled();
90 | $f_text->set_key("text");
91 | $f_text->set_val($this->text);
92 | $f_text->set_type(InnerFiled_Type::str);
93 | $actionChain2->set_field(1, $f_text);
94 |
95 | $f_title = new InnerFiled();
96 | $f_title->set_key("title");
97 | $f_title->set_val($this->title);
98 | $f_title->set_type(InnerFiled_Type::str);
99 | $actionChain2->set_field(2, $f_title);
100 |
101 | $f_logo = new InnerFiled();
102 | $f_logo->set_key("logo");
103 | $f_logo->set_val($this->logo);
104 | $f_logo->set_type(InnerFiled_Type::str);
105 | $actionChain2->set_field(3, $f_logo);
106 |
107 | $f_logoURL = new InnerFiled();
108 | $f_logoURL->set_key("logo_url");
109 | $f_logoURL->set_val($this->logoURL);
110 | $f_logoURL->set_type(InnerFiled_Type::str);
111 | $actionChain2->set_field(4, $f_logoURL);
112 |
113 | $f_notifyStyle = new InnerFiled();
114 | $f_notifyStyle->set_key("notifyStyle");
115 | $f_notifyStyle->set_val(strval($this->notifyStyle));
116 | $f_notifyStyle->set_type(InnerFiled_Type::str);
117 | $actionChain2->set_field(5, $f_notifyStyle);
118 |
119 | $f_isRing = new InnerFiled();
120 | $f_isRing->set_key("is_noring");
121 | $f_isRing->set_val(!$this->isRing ? "true" : "false");
122 | $f_isRing->set_type(InnerFiled_Type::bool);
123 | $actionChain2->set_field(6, $f_isRing);
124 |
125 | $f_isVibrate = new InnerFiled();
126 | $f_isVibrate->set_key("is_novibrate");
127 | $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false");
128 | $f_isVibrate->set_type(InnerFiled_Type::bool);
129 | $actionChain2->set_field(7, $f_isVibrate);
130 |
131 | $f_isClearable = new InnerFiled();
132 | $f_isClearable->set_key("is_noclear");
133 | $f_isClearable->set_val(!$this->isClearable ? "true" : "false");
134 | $f_isClearable->set_type(InnerFiled_Type::bool);
135 | $actionChain2->set_field(8, $f_isClearable);
136 |
137 | $f_channel = new InnerFiled();
138 | $f_channel->set_key("channel");
139 | $f_channel->set_val($this->channel);
140 | $f_channel->set_type(InnerFiled_Type::str);
141 | $actionChain2->set_field(9, $f_channel);
142 |
143 | $f_channelName = new InnerFiled();
144 | $f_channelName->set_key("channelName");
145 | $f_channelName->set_val($this->channelName);
146 | $f_channelName->set_type(InnerFiled_Type::str);
147 | $actionChain2->set_field(10, $f_channelName);
148 |
149 | $f_channelLevel = new InnerFiled();
150 | $f_channelLevel->set_key("channelLevel");
151 | $f_channelLevel->set_val(strval($this->channelLevel));
152 | $f_channelLevel->set_type(InnerFiled_Type::int32);
153 | $actionChain2->set_field(11, $f_channelLevel);
154 |
155 | $actionChain2->set_next(10010);
156 |
157 | $actionChain3 = new ActionChain();
158 | $actionChain3->set_actionId(10010);
159 | $actionChain3->set_type(ActionChain_Type::refer);
160 | $actionChain3->set_next(10020);
161 |
162 |
163 | //goto
164 | $actionChain3 = new ActionChain();
165 | $actionChain3->set_actionId(10010);
166 | $actionChain3->set_type(ActionChain_Type::refer);
167 | $actionChain3->set_next(10040);
168 |
169 |
170 | //启动web
171 | $actionChain4 = new ActionChain();
172 | $actionChain4->set_actionId(10040);
173 | $actionChain4->set_type(ActionChain_Type::startweb);
174 | $actionChain4->set_url($this->url);
175 | $actionChain4->set_next(100);
176 |
177 |
178 | //结束
179 | $actionChain5 = new ActionChain();
180 | $actionChain5->set_actionId(100);
181 | $actionChain5->set_type(ActionChain_Type::eoa);
182 |
183 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5);
184 |
185 | return $actionChains;
186 | }
187 |
188 | function get_pushType() {
189 | return 'LinkMsg';
190 | }
191 |
192 | function set_text($text) {
193 | $this->text = $text;
194 | }
195 |
196 | function set_title($title) {
197 | $this->title = $title;
198 | }
199 |
200 | function set_logo($logo) {
201 | $this->logo = $logo;
202 | }
203 |
204 | function set_logoURL($logoURL) {
205 | $this->logoURL = $logoURL;
206 | }
207 |
208 | function set_url($url) {
209 | $this->url = $url;
210 | }
211 |
212 | function set_isRing($isRing) {
213 | $this->isRing = $isRing;
214 | }
215 |
216 | function set_isVibrate($isVibrate) {
217 | $this->isVibrate = $isVibrate;
218 | }
219 |
220 | function set_isClearable($isClearable) {
221 | $this->isClearable = $isClearable;
222 | }
223 |
224 | function set_notifyStyle($notifyStyle) {
225 | if($notifyStyle != 1){
226 | $this->notifyStyle = 0;
227 | } else {
228 | $this->notifyStyle = 1;
229 | }
230 | }
231 |
232 | function set_channel($channel){
233 | if (!empty($channel)){
234 | $this->channel = $channel;
235 | }
236 | }
237 |
238 | function set_channelName($channelName){
239 | if (!empty($channelName)){
240 | $this->channelName = $channelName;
241 | }
242 | }
243 |
244 | function set_channelLevel($channelLevel){
245 | if ($channelLevel < 0 || $channelLevel > 4){
246 | throw new Exception("channelLevel should between 0 and 4");
247 | }
248 | $this->channelLevel = $channelLevel;
249 | }
250 |
251 | function set_notifyId($notifyId){
252 | if ($notifyId < 0){
253 | throw new Exception("notifyid need greater than 0");
254 | }
255 | if (!$this->get_pushInfo()->invalidAPN()){
256 | $apnJson = json_decode($this->get_pushInfo()->apnJson(), JSON_OBJECT_AS_ARRAY);
257 | $apnsCollapseId = $apnJson["apns-collapse-id"];
258 | if (empty($apnsCollapseId)){
259 | $apnJson["apns-collapse-id"] = $this->notifyId;
260 | $newApnJson = json_encode($apnJson);
261 | $this->get_pushInfo()->set_apnJson($newApnJson);
262 | }
263 | }
264 | $this->notifyId = $notifyId;
265 | }
266 |
267 | function set_apnInfo($payload){
268 | if ($payload instanceof IGtAPNPayload){
269 | if (!empty($this->notifyId) && empty($payload->get_apnsCollapseId())){
270 | $payload->set_apnsCollapseId($this->notifyId);
271 | }
272 | }
273 | parent::set_apnInfo($payload);
274 | }
275 |
276 | }
277 |
278 |
279 |
280 |
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.NotificationTemplate.php:
--------------------------------------------------------------------------------
1 | set_actionId(1);
42 | $actionChain1->set_type(ActionChain_Type::refer);
43 | $actionChain1->set_next(10000);
44 |
45 | //通知
46 | $actionChain2 = new ActionChain();
47 | $actionChain2->set_actionId(10000);
48 | $actionChain2->set_type(ActionChain_Type::mmsinbox2);
49 | $actionChain2->set_stype("notification");
50 |
51 | $f_notifyId = new InnerFiled();
52 | $f_notifyId->set_key("notifyid");
53 | $f_notifyId->set_val(empty($this->notifyId)?"":$this->notifyId);
54 | $f_notifyId->set_type(InnerFiled_Type::str);
55 | $actionChain2->set_field(0, $f_notifyId);
56 |
57 | $f_text = new InnerFiled();
58 | $f_text->set_key("text");
59 | $f_text->set_val($this->text);
60 | $f_text->set_type(InnerFiled_Type::str);
61 | $actionChain2->set_field(1, $f_text);
62 |
63 | $f_title = new InnerFiled();
64 | $f_title->set_key("title");
65 | $f_title->set_val($this->title);
66 | $f_title->set_type(InnerFiled_Type::str);
67 | $actionChain2->set_field(2, $f_title);
68 |
69 | $f_logo = new InnerFiled();
70 | $f_logo->set_key("logo");
71 | $f_logo->set_val($this->logo);
72 | $f_logo->set_type(InnerFiled_Type::str);
73 | $actionChain2->set_field(3, $f_logo);
74 |
75 | $f_logoURL = new InnerFiled();
76 | $f_logoURL->set_key("logo_url");
77 | $f_logoURL->set_val($this->logoURL);
78 | $f_logoURL->set_type(InnerFiled_Type::str);
79 | $actionChain2->set_field(4, $f_logoURL);
80 |
81 | $f_notifyStyle = new InnerFiled();
82 | $f_notifyStyle->set_key("notifyStyle");
83 | $f_notifyStyle->set_val(strval($this->notifyStyle));
84 | $f_notifyStyle->set_type(InnerFiled_Type::str);
85 | $actionChain2->set_field(5, $f_notifyStyle);
86 |
87 | $f_isRing = new InnerFiled();
88 | $f_isRing->set_key("is_noring");
89 | $f_isRing->set_val(!$this->isRing ? "true" : "false");
90 | $f_isRing->set_type(InnerFiled_Type::bool);
91 | $actionChain2->set_field(6, $f_isRing);
92 |
93 | $f_isVibrate = new InnerFiled();
94 | $f_isVibrate->set_key("is_novibrate");
95 | $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false");
96 | $f_isVibrate->set_type(InnerFiled_Type::bool);
97 | $actionChain2->set_field(7, $f_isVibrate);
98 |
99 | $f_isClearable = new InnerFiled();
100 | $f_isClearable->set_key("is_noclear");
101 | $f_isClearable->set_val(!$this->isClearable ? "true" : "false");
102 | $f_isClearable->set_type(InnerFiled_Type::bool);
103 | $actionChain2->set_field(8, $f_isClearable);
104 |
105 | $f_channel = new InnerFiled();
106 | $f_channel->set_key("channel");
107 | $f_channel->set_val($this->channel);
108 | $f_channel->set_type(InnerFiled_Type::str);
109 | $actionChain2->set_field(9, $f_channel);
110 |
111 | $f_channelName = new InnerFiled();
112 | $f_channelName->set_key("channelName");
113 | $f_channelName->set_val($this->channelName);
114 | $f_channelName->set_type(InnerFiled_Type::str);
115 | $actionChain2->set_field(10, $f_channelName);
116 |
117 | $f_channelLevel = new InnerFiled();
118 | $f_channelLevel->set_key("channelLevel");
119 | $f_channelLevel->set_val(strval($this->channelLevel));
120 | $f_channelLevel->set_type(InnerFiled_Type::int32);
121 | $actionChain2->set_field(11, $f_channelLevel);
122 |
123 | $actionChain2->set_next(10010);
124 |
125 | //goto
126 | $actionChain3 = new ActionChain();
127 | $actionChain3->set_actionId(10010);
128 | $actionChain3->set_type(ActionChain_Type::refer);
129 | $actionChain3->set_next(10030);
130 |
131 |
132 | //appStartUp
133 | $appStartUp = new AppStartUp();
134 | $appStartUp->set_android("");
135 | $appStartUp->set_symbia("");
136 | $appStartUp->set_ios("");
137 |
138 | //启动app
139 | $actionChain4 = new ActionChain();
140 | $actionChain4->set_actionId(10030);
141 | $actionChain4->set_type(ActionChain_Type::startapp);
142 | $actionChain4->set_appid("");
143 | $actionChain4->set_autostart($this->transmissionType == '1'? true : false);
144 | $actionChain4->set_appstartupid($appStartUp);
145 | $actionChain4->set_failedAction(100);
146 | $actionChain4->set_next(100);
147 |
148 |
149 | //结束
150 | $actionChain5 = new ActionChain();
151 | $actionChain5->set_actionId(100);
152 | $actionChain5->set_type(ActionChain_Type::eoa);
153 |
154 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5);
155 |
156 | return $actionChains;
157 | }
158 |
159 | function get_transmissionContent() {
160 | return $this->transmissionContent;
161 | }
162 |
163 | function get_pushType() {
164 | return 'NotifyMsg';
165 | }
166 |
167 | function set_text($text) {
168 | $this->text = $text;
169 | }
170 |
171 | function set_title($title) {
172 | $this->title = $title;
173 | }
174 |
175 | function set_logo($logo) {
176 | $this->logo = $logo;
177 | }
178 |
179 | function set_logoURL($logoURL) {
180 | $this->logoURL = $logoURL;
181 | }
182 |
183 | function set_transmissionType($transmissionType) {
184 | $this->transmissionType = $transmissionType;
185 | }
186 |
187 | function set_isRing($isRing) {
188 | $this->isRing = $isRing;
189 | }
190 |
191 | function set_isVibrate($isVibrate) {
192 | $this->isVibrate = $isVibrate;
193 | }
194 |
195 | function set_isClearable($isClearable) {
196 | $this->isClearable = $isClearable;
197 | }
198 |
199 | function set_transmissionContent($transmissionContent) {
200 | $this->transmissionContent = $transmissionContent;
201 | }
202 |
203 | function set_notifyStyle($notifyStyle) {
204 | if($notifyStyle != 1){
205 | $this->notifyStyle = 0;
206 | } else {
207 | $this->notifyStyle = 1;
208 | }
209 | }
210 |
211 | function set_channel($channel){
212 | if (!empty($channel)){
213 | $this->channel = $channel;
214 | }
215 | }
216 |
217 | function set_channelName($channelName){
218 | if (!empty($channelName)){
219 | $this->channelName = $channelName;
220 | }
221 | }
222 |
223 | function set_channelLevel($channelLevel){
224 | if ($channelLevel < 0 || $channelLevel > 4){
225 | throw new Exception("channelLevel should between 0 and 4");
226 | }
227 | $this->channelLevel = $channelLevel;
228 | }
229 |
230 | function set_notifyId($notifyId){
231 | if ($notifyId < 0){
232 | throw new Exception("notifyid need greater than 0");
233 | }
234 | if (!$this->get_pushInfo()->invalidAPN()){
235 | $apnJson = json_decode($this->get_pushInfo()->apnJson(), JSON_OBJECT_AS_ARRAY);
236 | $apnsCollapseId = $apnJson["apns-collapse-id"];
237 | if (empty($apnsCollapseId)){
238 | $apnJson["apns-collapse-id"] = $this->notifyId;
239 | $newApnJson = json_encode($apnJson);
240 | $this->get_pushInfo()->set_apnJson($newApnJson);
241 | }
242 | }
243 | $this->notifyId = $notifyId;
244 | }
245 |
246 | function set_apnInfo($payload){
247 | if ($payload instanceof IGtAPNPayload){
248 | if (!empty($this->notifyId) && empty($payload->get_apnsCollapseId())){
249 | $payload->set_apnsCollapseId($this->notifyId);
250 | }
251 | }
252 | parent::set_apnInfo($payload);
253 | }
254 | }
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.NotyPopLoadTemplate.php:
--------------------------------------------------------------------------------
1 | set_actionId(1);
105 | $actionChain1->set_type(ActionChain_Type::refer);
106 | $actionChain1->set_next(10000);
107 | //通知
108 | $actionChain2 = new ActionChain();
109 | $actionChain2->set_actionId(10000);
110 | $actionChain2->set_type(ActionChain_Type::mmsinbox2);
111 | $actionChain2->set_stype("notification");
112 |
113 | $f_notifyId = new InnerFiled();
114 | $f_notifyId->set_key("notifyid");
115 | $f_notifyId->set_val(empty($this->notifyId)?"":$this->notifyId);
116 | $f_notifyId->set_type(InnerFiled_Type::str);
117 | $actionChain2->set_field(0, $f_notifyId);
118 |
119 | $f_text = new InnerFiled();
120 | $f_text->set_key("text");
121 | $f_text->set_val($this->notyContent);
122 | $f_text->set_type(InnerFiled_Type::str);
123 | $actionChain2->set_field(1, $f_text);
124 |
125 | $f_title = new InnerFiled();
126 | $f_title->set_key("title");
127 | $f_title->set_val($this->notyTitle);
128 | $f_title->set_type(InnerFiled_Type::str);
129 | $actionChain2->set_field(2, $f_title);
130 |
131 | $f_logo = new InnerFiled();
132 | $f_logo->set_key("logo");
133 | $f_logo->set_val($this->notyIcon);
134 | $f_logo->set_type(InnerFiled_Type::str);
135 | $actionChain2->set_field(3, $f_logo);
136 |
137 | $f_logoURL = new InnerFiled();
138 | $f_logoURL->set_key("logo_url");
139 | $f_logoURL->set_val($this->logoURL);
140 | $f_logoURL->set_type(InnerFiled_Type::str);
141 | $actionChain2->set_field(4, $f_logoURL);
142 |
143 | $f_notifyStyle = new InnerFiled();
144 | $f_notifyStyle->set_key("notifyStyle");
145 | $f_notifyStyle->set_val(strval($this->notifyStyle));
146 | $f_notifyStyle->set_type(InnerFiled_Type::str);
147 | $actionChain2->set_field(5, $f_notifyStyle);
148 |
149 | $f_isRing = new InnerFiled();
150 | $f_isRing->set_key("is_noring");
151 | $f_isRing->set_val(!$this->isBelled ? "true" : "false");
152 | $f_isRing->set_type(InnerFiled_Type::bool);
153 | $actionChain2->set_field(6, $f_isRing);
154 |
155 | $f_isVibrate = new InnerFiled();
156 | $f_isVibrate->set_key("is_novibrate");
157 | $f_isVibrate->set_val(!$this->isVibrationed ? "true" : "false");
158 | $f_isVibrate->set_type(InnerFiled_Type::bool);
159 | $actionChain2->set_field(7, $f_isVibrate);
160 |
161 | $f_isClearable = new InnerFiled();
162 | $f_isClearable->set_key("is_noclear");
163 | $f_isClearable->set_val(!$this->isCleared ? "true" : "false");
164 | $f_isClearable->set_type(InnerFiled_Type::bool);
165 | $actionChain2->set_field(8, $f_isClearable);
166 |
167 | $f_channel = new InnerFiled();
168 | $f_channel->set_key("channel");
169 | $f_channel->set_val($this->channel);
170 | $f_channel->set_type(InnerFiled_Type::str);
171 | $actionChain2->set_field(9, $f_channel);
172 |
173 | $f_channelName = new InnerFiled();
174 | $f_channelName->set_key("channelName");
175 | $f_channelName->set_val($this->channelName);
176 | $f_channelName->set_type(InnerFiled_Type::str);
177 | $actionChain2->set_field(10, $f_channelName);
178 |
179 | $f_channelLevel = new InnerFiled();
180 | $f_channelLevel->set_key("channelLevel");
181 | $f_channelLevel->set_val(strval($this->channelLevel));
182 | $f_channelLevel->set_type(InnerFiled_Type::int32);
183 | $actionChain2->set_field(11, $f_channelLevel);
184 |
185 | $actionChain2->set_next(10010);
186 |
187 | $actionChain3 = new ActionChain();
188 | $actionChain3->set_actionId(10010);
189 | $actionChain3->set_type(ActionChain_Type::refer);
190 | $actionChain3->set_next(10020);
191 |
192 | //弹框按钮
193 | $button1 = new Button();
194 | $button1->set_text($this->popButton1);
195 | $button1->set_next(10050);
196 | $button2 = new Button();
197 | $button2->set_text($this->popButton2);
198 | $button2->set_next(100);
199 |
200 | //弹框
201 | $actionChain4 = new ActionChain();
202 | $actionChain4->set_actionId(10020);
203 | $actionChain4->set_type(ActionChain_Type::popup);
204 | $actionChain4->set_title($this->popTitle);
205 | $actionChain4->set_text($this->popContent);
206 | $actionChain4->set_img($this->popImage);
207 | $actionChain4->set_buttons(0,$button1);
208 | $actionChain4->set_buttons(1,$button2);
209 | $actionChain4->set_next(6);
210 |
211 | //下载
212 | //appstartupid
213 | $appStartUp = new AppStartUp();
214 | $appStartUp->set_android($this->androidMark);
215 | $appStartUp->set_Ios($this->iosMark);
216 | $appStartUp->set_symbia($this->symbianMark);
217 | $actionChain5 = new ActionChain();
218 | $actionChain5->set_actionId(10050);
219 | $actionChain5->set_type(ActionChain_Type::appdownload);
220 | $actionChain5->set_name($this->loadTitle);
221 | $actionChain5->set_url($this->loadUrl);
222 | $actionChain5->set_logo($this->loadIcon);
223 | $actionChain5->set_autoInstall($this->isAutoInstall);
224 | $actionChain5->set_autostart($this->isActived);
225 | $actionChain5->set_appstartupid($appStartUp);
226 | $actionChain5->set_next(6);
227 |
228 | $actionChain6 = new ActionChain();
229 | $actionChain6->set_actionId(100);
230 | $actionChain6->set_type(ActionChain_Type::eoa);
231 |
232 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5,$actionChain6);
233 | return $actionChains;
234 | }
235 |
236 | function set_notyIcon($notyIcon) {
237 | $this->notyIcon = $notyIcon;
238 | }
239 | function set_notyTitle($notyTitle) {
240 | $this->notyTitle = $notyTitle;
241 | }
242 | function set_logoURL($logoURL) {
243 | $this->logoURL = $logoURL;
244 | }
245 | function set_notyContent($notyContent) {
246 | $this->notyContent = $notyContent;
247 | }
248 | function set_isCleared($isCleared) {
249 | $this->isCleared = $isCleared;
250 | }
251 | function set_isBelled($isBelled) {
252 | $this->isBelled = $isBelled;
253 | }
254 | function set_isVibrationed($isVibrationed) {
255 | $this->isVibrationed = $isVibrationed;
256 | }
257 | function set_popTitle($popTitle) {
258 | $this->popTitle = $popTitle;
259 | }
260 | function set_popContent($popContent) {
261 | $this->popContent = $popContent;
262 | }
263 | function set_popImage($popImage) {
264 | $this->popImage = $popImage;
265 | }
266 | function set_popButton1($popButton1) {
267 | $this->popButton1 = $popButton1;
268 | }
269 | function set_popButton2($popButton2) {
270 | $this->popButton2 = $popButton2;
271 | }
272 | function set_loadIcon($loadIcon) {
273 | $this->loadIcon = $loadIcon;
274 | }
275 | function set_loadTitle($loadTitle) {
276 | $this->loadTitle = $loadTitle;
277 | }
278 | function set_loadUrl($loadUrl) {
279 | $this->loadUrl = $loadUrl;
280 | }
281 | function set_isAutoInstall($isAutoInstall) {
282 | $this->isAutoInstall = $isAutoInstall;
283 | }
284 | function set_isActived($isActived) {
285 | $this->isActived = $isActived;
286 | }
287 | function set_symbianMark($symbianMark){
288 | $this->symbianMark = $symbianMark;
289 | }
290 | function set_androidMark($androidMark){
291 | $this->androidMark = $androidMark;
292 | }
293 | function set_iosMark($iosMark){
294 | $this->iosMark = $iosMark;
295 | }
296 | function get_pushType(){
297 | return "NotyPopLoadTemplate";
298 | }
299 |
300 | function set_notifyStyle($notifyStyle) {
301 | if($notifyStyle != 1){
302 | $this->notifyStyle = 0;
303 | } else {
304 | $this->notifyStyle = 1;
305 | }
306 | }
307 |
308 | function set_channel($channel){
309 | if (!empty($channel)){
310 | $this->channel = $channel;
311 | }
312 | }
313 |
314 | function set_channelName($channelName){
315 | if (!empty($channelName)){
316 | $this->channelName = $channelName;
317 | }
318 | }
319 |
320 | function set_channelLevel($channelLevel){
321 | if ($channelLevel < 0 || $channelLevel > 4){
322 | throw new Exception("channelLevel should between 0 and 4");
323 | }
324 | $this->channelLevel = $channelLevel;
325 | }
326 |
327 | function set_notifyId($notifyId){
328 | if ($notifyId < 0){
329 | throw new Exception("notifyid need greater than 0");
330 | }
331 | if (!$this->get_pushInfo()->invalidAPN()){
332 | $apnJson = json_decode($this->get_pushInfo()->apnJson(), JSON_OBJECT_AS_ARRAY);
333 | $apnsCollapseId = $apnJson["apns-collapse-id"];
334 | if (empty($apnsCollapseId)){
335 | $apnJson["apns-collapse-id"] = $this->notifyId;
336 | $newApnJson = json_encode($apnJson);
337 | $this->get_pushInfo()->set_apnJson($newApnJson);
338 | }
339 | }
340 | $this->notifyId = $notifyId;
341 | }
342 |
343 | function set_apnInfo($payload){
344 | if ($payload instanceof IGtAPNPayload){
345 | if (!empty($this->notifyId) && empty($payload->get_apnsCollapseId())){
346 | $payload->set_apnsCollapseId($this->notifyId);
347 | }
348 | }
349 | parent::set_apnInfo($payload);
350 | }
351 | }
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.RevokeTemplate.php:
--------------------------------------------------------------------------------
1 | set_actionId(1);
21 | $actionChain1->set_type(ActionChain_Type::mmsinbox2);
22 | $actionChain1->set_stype("terminatetask");
23 |
24 | $f_force = new InnerFiled();
25 | $f_force->set_key("force");
26 | $f_force->set_val($this->force ? "true" : "false");
27 | $f_force->set_type(InnerFiled_Type::bool);
28 | $actionChain1->set_field(0, $f_force);
29 |
30 | $f_taskId = new InnerFiled();
31 | $f_taskId->set_key("taskid");
32 | $f_taskId->set_val($this->oldTaskId);
33 | $f_taskId->set_type(InnerFiled_Type::str);
34 | $actionChain1->set_field(1, $f_taskId);
35 |
36 | $actionChain1->set_next(100);
37 |
38 | //结束
39 | $actionChain2 = new ActionChain();
40 | $actionChain2->set_actionId(100);
41 | $actionChain2->set_type(ActionChain_Type::eoa);
42 |
43 | array_push($actionChains, $actionChain1,$actionChain2);
44 |
45 | return $actionChains;
46 | }
47 |
48 | function get_pushType() {
49 | return 'Revoke';
50 | }
51 |
52 | function get_force(){
53 | return $this->force;
54 | }
55 |
56 | function set_force($force){
57 | $this->force = $force;
58 | }
59 |
60 | function get_oldTaskId(){
61 | return $this->oldTaskId;
62 | }
63 |
64 | function set_oldTaskId($oldTaskId){
65 | $this->oldTaskId = $oldTaskId;
66 | }
67 | }
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.StartActivityTemplate.php:
--------------------------------------------------------------------------------
1 | set_actionId(1);
31 | $actionChain1->set_type(ActionChain_Type::refer);
32 | $actionChain1->set_next(10000);
33 |
34 | $actionChain2 = new ActionChain();
35 | $actionChain2->set_actionId(10000);
36 | $actionChain2->set_type(ActionChain_Type::mmsinbox2);
37 | $actionChain2->set_stype("notification");
38 |
39 | $f_notifyId = new InnerFiled();
40 | $f_notifyId->set_key("notifyid");
41 | $f_notifyId->set_val(empty($this->notifyId)?"":$this->notifyId);
42 | $f_notifyId->set_type(InnerFiled_Type::str);
43 | $actionChain2->set_field(0, $f_notifyId);
44 |
45 | $f_text = new InnerFiled();
46 | $f_text->set_key("text");
47 | $f_text->set_val($this->text);
48 | $f_text->set_type(InnerFiled_Type::str);
49 | $actionChain2->set_field(1, $f_text);
50 |
51 | $f_title = new InnerFiled();
52 | $f_title->set_key("title");
53 | $f_title->set_val($this->title);
54 | $f_title->set_type(InnerFiled_Type::str);
55 | $actionChain2->set_field(2, $f_title);
56 |
57 | $f_logo = new InnerFiled();
58 | $f_logo->set_key("logo");
59 | $f_logo->set_val($this->logo);
60 | $f_logo->set_type(InnerFiled_Type::str);
61 | $actionChain2->set_field(3, $f_logo);
62 |
63 | $f_logoURL = new InnerFiled();
64 | $f_logoURL->set_key("logo_url");
65 | $f_logoURL->set_val($this->logoURL);
66 | $f_logoURL->set_type(InnerFiled_Type::str);
67 | $actionChain2->set_field(4, $f_logoURL);
68 |
69 | $f_notifyStyle = new InnerFiled();
70 | $f_notifyStyle->set_key("notifyStyle");
71 | $f_notifyStyle->set_val(strval($this->notifyStyle));
72 | $f_notifyStyle->set_type(InnerFiled_Type::str);
73 | $actionChain2->set_field(5, $f_notifyStyle);
74 |
75 | $f_isRing = new InnerFiled();
76 | $f_isRing->set_key("is_noring");
77 | $f_isRing->set_val(!$this->isRing ? "true" : "false");
78 | $f_isRing->set_type(InnerFiled_Type::bool);
79 | $actionChain2->set_field(6, $f_isRing);
80 |
81 | $f_isVibrate = new InnerFiled();
82 | $f_isVibrate->set_key("is_novibrate");
83 | $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false");
84 | $f_isVibrate->set_type(InnerFiled_Type::bool);
85 | $actionChain2->set_field(7, $f_isVibrate);
86 |
87 | $f_isClearable = new InnerFiled();
88 | $f_isClearable->set_key("is_noclear");
89 | $f_isClearable->set_val(!$this->isClearable ? "true" : "false");
90 | $f_isClearable->set_type(InnerFiled_Type::bool);
91 | $actionChain2->set_field(8, $f_isClearable);
92 |
93 | $actionChain2->set_next(10010);
94 |
95 | $actionChain3 = new ActionChain();
96 | $actionChain3->set_actionId(10010);
97 | $actionChain3->set_type(ActionChain_Type::refer);
98 | $actionChain3->set_next(11220);
99 |
100 | $actionChain4 = new ActionChain();
101 | $actionChain4->set_actionId(11220);
102 | $actionChain4->set_type(ActionChain_Type::mmsinbox2);
103 | $actionChain4->set_stype("startmyactivity");
104 |
105 | $f_uri = new InnerFiled();
106 | $f_uri->set_key("uri");
107 | $f_uri->set_val($this->get_intent());
108 | $f_uri->set_type(InnerFiled_Type::str);
109 | $actionChain4->set_field(0,$f_uri);
110 |
111 | $f_doFailed = new InnerFiled();
112 | $f_doFailed->set_key("do_failed");
113 | $f_doFailed->set_val("100");
114 | $f_doFailed->set_type(InnerFiled_Type::str);
115 | $actionChain4->set_field(1,$f_doFailed);
116 |
117 | $actionChain4->set_next(100);
118 |
119 | $actionChain5 = new ActionChain();
120 | $actionChain5->set_actionId(100);
121 | $actionChain5->set_type(ActionChain_Type::eoa);
122 |
123 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5);
124 |
125 | return $actionChains;
126 | }
127 |
128 | function get_pushType() {
129 | return 'StartActivity';
130 | }
131 |
132 | function set_intent($intent){
133 | if(strlen($intent) > GTConfig::getStartActivityIntentLimit()){
134 | throw new Exception("intent size overlimit " . GTConfig::getStartActivityIntentLimit());
135 | }
136 | //不符合intent的格式要求
137 | if(!preg_match(self::pattern,$intent)){
138 | throw new Exception("intent format err,should start with \"intent:#Intent;\",end \"with ;end\" ");
139 | }
140 |
141 | $this -> intent = $intent;
142 |
143 | }
144 |
145 | function get_intent(){
146 | return $this->intent==null?"":$this->intent;
147 | }
148 |
149 | /**
150 | * @param mixed $text
151 | */
152 | public function set_text($text)
153 | {
154 | $this->text = $text;
155 | }
156 |
157 | /**
158 | * @param mixed $title
159 | */
160 | public function set_title($title)
161 | {
162 | $this->title = $title;
163 | }
164 |
165 | /**
166 | * @param mixed $logo
167 | */
168 | public function set_logo($logo)
169 | {
170 | $this->logo = $logo;
171 | }
172 |
173 | /**
174 | * @param mixed $logoURL
175 | */
176 | public function set_logoURL($logoURL)
177 | {
178 | $this->logoURL = $logoURL;
179 | }
180 |
181 | /**
182 | * @param mixed $notifyStyle
183 | */
184 | public function set_notifyStyle($notifyStyle)
185 | {
186 | $this->notifyStyle = $notifyStyle;
187 | }
188 |
189 | /**
190 | * @param mixed $isRing
191 | */
192 | public function set_isRing($isRing)
193 | {
194 | $this->isRing = $isRing;
195 | }
196 |
197 | /**
198 | * @param mixed $isVibrate
199 | */
200 | public function set_isVibrate($isVibrate)
201 | {
202 | $this->isVibrate = $isVibrate;
203 | }
204 |
205 | /**
206 | * @param mixed $isClearable
207 | */
208 | public function set_isClearable($isClearable)
209 | {
210 | $this->isClearable = $isClearable;
211 | }
212 |
213 | function set_notifyId($notifyId){
214 | if ($notifyId < 0){
215 | throw new Exception("notifyid need greater than 0");
216 | }
217 | if (!$this->get_pushInfo()->invalidAPN()){
218 | $apnJson = json_decode($this->get_pushInfo()->apnJson(), JSON_OBJECT_AS_ARRAY);
219 | $apnsCollapseId = $apnJson["apns-collapse-id"];
220 | if (empty($apnsCollapseId)){
221 | $apnJson["apns-collapse-id"] = $this->notifyId;
222 | $newApnJson = json_encode($apnJson);
223 | $this->get_pushInfo()->set_apnJson($newApnJson);
224 | }
225 | }
226 | $this->notifyId = $notifyId;
227 | }
228 |
229 | function set_apnInfo($payload){
230 | if ($payload instanceof IGtAPNPayload){
231 | if (!empty($this->notifyId) && empty($payload->get_apnsCollapseId())){
232 | $payload->set_apnsCollapseId($this->notifyId);
233 | }
234 | }
235 | parent::set_apnInfo($payload);
236 | }
237 | }
--------------------------------------------------------------------------------
/getui/igetui/template/IGt.TransmissionTemplate.php:
--------------------------------------------------------------------------------
1 | set_actionId(1);
16 | $actionChain1->set_type(ActionChain_Type::refer);
17 | $actionChain1->set_next(10030);
18 |
19 | //appStartUp
20 | $appStartUp = new AppStartUp();
21 | $appStartUp->set_android("");
22 | $appStartUp->set_symbia("");
23 | $appStartUp->set_ios("");
24 |
25 | //启动app
26 | $actionChain2 = new ActionChain();
27 | $actionChain2->set_actionId(10030);
28 | $actionChain2->set_type(ActionChain_Type::startapp);
29 | $actionChain2->set_appid("");
30 | $actionChain2->set_autostart($this->transmissionType == '1'? true : false);
31 | $actionChain2->set_appstartupid($appStartUp);
32 | $actionChain2->set_failedAction(100);
33 | $actionChain2->set_next(100);
34 |
35 | //结束
36 | $actionChain3 = new ActionChain();
37 | $actionChain3->set_actionId(100);
38 | $actionChain3->set_type(ActionChain_Type::eoa);
39 |
40 |
41 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3);
42 |
43 | return $actionChains;
44 | }
45 |
46 | function get_transmissionContent() {
47 | return $this->transmissionContent;
48 | }
49 |
50 | function get_pushType() {
51 | return 'TransmissionMsg';
52 | }
53 |
54 |
55 | function set_transmissionType($transmissionType) {
56 | $this->transmissionType = $transmissionType;
57 | }
58 |
59 | function set_transmissionContent($transmissionContent) {
60 | $this->transmissionContent = $transmissionContent;
61 | }
62 |
63 | function set3rdNotifyInfo(IGtNotify $notify) {
64 | if (!$this->get_pushInfo()->invalidAPN()){
65 | if (!empty($notify->notifyId)){
66 | $apnJson = json_decode($this->get_pushInfo()->apnJson(), JSON_OBJECT_AS_ARRAY);
67 | $apnsCollapseId = $apnJson["apns-collapse-id"];
68 | if (empty($apnsCollapseId)){
69 | $apnJson["apns-collapse-id"] = $this->notifyId;
70 | $newApnJson = json_encode($apnJson);
71 | $this->get_pushInfo()->set_apnJson($newApnJson);
72 | }
73 | }
74 | }
75 | if ($notify->get_title() == null || $notify -> get_content() == null) {
76 | throw new Exception("notify title or content cannot be null");
77 | }
78 |
79 | $notifyInfo = new NotifyInfo();
80 | $notifyInfo -> set_title($notify -> get_title());
81 | $notifyInfo -> set_content($notify -> get_content());
82 |
83 | //不指定类型,只发简单通知 ,php 中 空串、false、0、null的值都是相等的,type的枚举值都是大于等于0的
84 | if($notify -> get_type() > -1){
85 | $notifyInfo ->set_type($notify -> get_type());
86 | if($notify -> get_payload() != null){
87 | $notifyInfo -> set_payload($notify -> get_payload());
88 | }
89 |
90 | if($notify -> get_intent() != null){
91 | if(strlen($notify -> get_intent()) > GTConfig::getNotifyIntentLimit()){
92 | throw new Exception("intent size overlimit " . GTConfig::getNotifyIntentLimit());
93 | }
94 | //不符合intent的格式要求
95 | if(!preg_match(self::pattern,$notify -> get_intent())){
96 | throw new Exception("intent format err,should start with \"intent:#Intent;\",end \"with ;end\" ");
97 | }
98 |
99 | $notifyInfo -> set_intent($notify -> get_intent());
100 | }elseif (NotifyInfo_Type::_intent == $notify -> get_type()){
101 | $notifyInfo->set_intent("");
102 | }
103 |
104 | if($notify -> get_url() != null){
105 | $notifyInfo ->set_url($notify -> get_url());
106 | }
107 | }
108 |
109 | if (!empty($notify->get_notifyId())){
110 | $notifyInfo->set_notifyId($notify->get_notifyId());
111 | }
112 |
113 | $extKVs = $notify->extKVList;
114 | if (!empty($extKVs)){
115 | echo "begin extKVList trans";
116 | $count = count($extKVs);
117 | for ($i=0; $i<$count; ++$i){
118 | $extKV = new ExtKV();
119 | $extKV->set_key($extKVs[$i]->get_key());
120 | $extKV->set_value($extKVs[$i]->get_value());
121 | $extKV->set_constains($extKVs[$i]->get_constrains());
122 | $notifyInfo->set_extKV($i, $extKV);
123 | }
124 | }
125 | $pushInfo = $this-> get_pushInfo();
126 | $pushInfo -> set_notifyInfo($notifyInfo);
127 | $pushInfo -> set_validNotify(true);
128 | }
129 |
130 | function set_apnInfo($payload){
131 | if ($payload instanceof IGtAPNPayload){
132 | $notifyInfo = $this->get_pushInfo()->notifyInfo();
133 | if (!empty($notifyId)){
134 | $notifyId = $notifyInfo->notifyId();
135 | if (!empty($notifyId) && empty($payload->get_apnsCollapseId())){
136 | $payload->set_apnsCollapseId($notifyId);
137 | }
138 | }
139 | }
140 | parent::set_apnInfo($payload);
141 | }
142 | }
--------------------------------------------------------------------------------
/getui/igetui/template/notify/IGt.Notify.php:
--------------------------------------------------------------------------------
1 | title;
56 | }
57 |
58 | /**
59 | * @param mixed $title
60 | */
61 | public function set_title($title)
62 | {
63 | $this->title = $title;
64 | }
65 |
66 | /**
67 | * @return mixed
68 | */
69 | public function get_content()
70 | {
71 | return $this->content;
72 | }
73 |
74 | /**
75 | * @param mixed $content
76 | */
77 | public function set_content($content)
78 | {
79 | $this->content = $content;
80 | }
81 |
82 | /**
83 | * @return mixed
84 | */
85 | public function get_payload()
86 | {
87 | return $this->payload;
88 | }
89 |
90 | /**
91 | * @param mixed $payload
92 | */
93 | public function set_payload($payload)
94 | {
95 | $this->payload = $payload;
96 | }
97 |
98 | /**
99 | * @return mixed
100 | */
101 | public function get_url()
102 | {
103 | return $this->url;
104 | }
105 |
106 | /**
107 | * @param mixed $url
108 | */
109 | public function set_url($url)
110 | {
111 | $this->url = $url;
112 | }
113 |
114 | /**
115 | * @return mixed
116 | */
117 | public function get_intent()
118 | {
119 | return $this->intent;
120 | }
121 |
122 | /**
123 | * @param mixed $intent
124 | */
125 | public function set_intent($intent)
126 | {
127 | $this->intent = $intent;
128 | }
129 |
130 | /**
131 | * @return mixed
132 | */
133 | public function get_type()
134 | {
135 | return $this->type;
136 | }
137 |
138 | /**
139 | * @param mixed $type
140 | */
141 | public function set_type($type)
142 | {
143 | $this->type = $type;
144 | }
145 |
146 | function set_notifyId($notifyId){
147 | if ($notifyId < 0){
148 | throw new Exception("notifyid need greater than 0");
149 | }
150 | $this->notifyId = $notifyId;
151 | }
152 |
153 | function get_notifyId(){
154 | return $this->notifyId;
155 | }
156 |
157 | function get_extKVList(){
158 | return $this->extKVList;
159 | }
160 |
161 | function addExtKVToAll($key, $value){
162 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::ALL);
163 | return $this;
164 | }
165 |
166 | function addHWExtKV($key, $value){
167 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::HW);
168 | return $this;
169 | }
170 | function addXMExtKV($key, $value){
171 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::XM);
172 | return $this;
173 | }
174 | function addMZExtKV($key, $value){
175 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::MZ);
176 | return $this;
177 | }
178 | function addOPExtKV($key, $value){
179 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::OP);
180 | return $this;
181 | }
182 | function addVVExtKV($key, $value){
183 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::VV);
184 | return $this;
185 | }
186 |
187 | function addFCMExtKV($key, $value){
188 | $this->extKVList[] = new NotifyExtKV($key, $value, PlatformConstains::FCM);
189 | return $this;
190 | }
191 | }
192 |
193 | class PlatformConstains
194 | {
195 | const HW = 'HW';
196 | const XM = 'XM';
197 | const VV = 'VV';
198 | const MZ = 'MZ';
199 | const FCM = 'FCM';
200 | const OP = 'OP';
201 | const ALL = "ALL";
202 | }
203 |
204 | class NotifyExtKV{
205 | var $key;
206 | var $value;
207 | var $constrains = PlatformConstains::ALL;
208 |
209 | function __construct($key, $value, $constrains)
210 | {
211 | $this->key = $key;
212 | $this->value = json_encode($value);
213 | $this->constrains = $constrains;
214 | }
215 |
216 | function get_key(){
217 | return $this->key;
218 | }
219 | function get_value(){
220 | return $this->value;
221 | }
222 | function get_constrains(){
223 | return $this->constrains;
224 | }
225 | function set_key($key){
226 | $this->key = $key;
227 | }
228 |
229 | }
--------------------------------------------------------------------------------
/getui/igetui/template/notify/SmsMessage.php:
--------------------------------------------------------------------------------
1 | smsTemplateId;
31 | }
32 |
33 | /**
34 | * @param mixed $smsTemplateId
35 | */
36 | public function setSmsTemplateId($smsTemplateId)
37 | {
38 | $this->smsTemplateId = $smsTemplateId;
39 | }
40 |
41 | /**
42 | * @return mixed
43 | */
44 | public function getSmsContent()
45 | {
46 | return $this->smsContent;
47 | }
48 |
49 | /**
50 | * @param mixed $smsContent
51 | */
52 | public function setSmsContent($smsContent)
53 | {
54 | $this->smsContent = $smsContent;
55 | }
56 |
57 | /**
58 | * @return mixed
59 | */
60 | public function getOfflineSendtime()
61 | {
62 | return $this->offlineSendtime;
63 | }
64 |
65 | /**
66 | * @param mixed $offlineSendtime
67 | */
68 | public function setOfflineSendtime($offlineSendtime)
69 | {
70 | $this->offlineSendtime = $offlineSendtime;
71 | }
72 |
73 |
74 | /**
75 | * @return mixed
76 | */
77 | public function getUrl()
78 | {
79 | return $this->url;
80 | }
81 |
82 | /**
83 | * @param mixed $url
84 | */
85 | public function setUrl($url)
86 | {
87 | $this->url = $url;
88 | }
89 |
90 | /**
91 | * @return mixed
92 | */
93 | public function getisApplink()
94 | {
95 | return $this->isApplink;
96 | }
97 |
98 | /**
99 | * @param mixed $isApplink
100 | */
101 | public function setIsApplink($isApplink)
102 | {
103 | $this->isApplink = $isApplink;
104 | }
105 |
106 | /**
107 | * @return mixed
108 | */
109 | public function getPayload()
110 | {
111 | return $this->payload;
112 | }
113 |
114 | /**
115 | * @param mixed $payload
116 | */
117 | public function setPayload($payload)
118 | {
119 | $this->payload = $payload;
120 | }//自定义字段
121 |
122 | }
123 |
124 | ?>
--------------------------------------------------------------------------------
/getui/igetui/utils/ApiUrlRespectUtils.php:
--------------------------------------------------------------------------------
1 | $diff)
48 | {
49 | $mint=$diff;
50 | $s_url=$hosts[$i];
51 | }
52 | }
53 | return $s_url;
54 | }
55 | }
--------------------------------------------------------------------------------
/getui/igetui/utils/ApnsUtils.php:
--------------------------------------------------------------------------------
1 | 0) {
22 | // loc-key
23 | $pb->setAlertLocKey(($locKey));
24 | // loc-args
25 | if ($locArgs != null && strlen($locArgs) > 0) {
26 | $pb->setAlertLocArgs(explode(',',($locArgs)));
27 | }
28 | $isValid = true;
29 | }
30 |
31 | // body
32 | if ($message != null && strlen($message) > 0) {
33 | $pb->setAlertBody(($message));
34 | $isValid = true;
35 | }
36 |
37 | // action-loc-key
38 | if ($actionLocKey!=null && strlen($actionLocKey) > 0) {
39 | $pb->setAlertActionLocKey($actionLocKey);
40 | }
41 |
42 | // launch-image
43 | if ($launchImage!=null && strlen($launchImage) > 0) {
44 | $pb->setAlertLaunchImage($launchImage);
45 | }
46 |
47 | // badge
48 | $badgeNum = -1;
49 | if(is_numeric($badge)){
50 | $badgeNum = (int)$badge;
51 | }
52 | if ($badgeNum >= 0) {
53 | $pb->setBadge($badgeNum);
54 | $isValid = true;
55 | }
56 |
57 | // sound
58 | if ($sound != null && strlen($sound) > 0) {
59 | $pb->setSound($sound);
60 | } else {
61 | $pb->setSound("default");
62 | }
63 |
64 | //contentAvailable
65 | if ($contentAvailable == 1) {
66 | $pb->setContentAvailable(1);
67 | $isValid = true;
68 | }
69 |
70 | // payload
71 | if ($payload != null && strlen($payload) > 0) {
72 | $pb->addParam("payload", ($payload));
73 | }
74 |
75 | if($isValid == false){
76 | throw new Exception("one of the params(locKey,message,badge) must not be null or contentAvailable must be 1");
77 | }
78 | $json = $pb->toString();
79 | if($json == null){
80 | throw new Exception("payload json is null");
81 | }
82 | return $json;
83 | }
84 | }
85 |
86 | Class Payload
87 | {
88 | var $APS = "aps";
89 | var $params;
90 | var $alert;
91 | var $badge;
92 | var $sound = "";
93 |
94 | var $alertBody;
95 | var $alertActionLocKey;
96 | var $alertLocKey;
97 | var $alertLocArgs;
98 | var $alertLaunchImage;
99 | var $contentAvailable;
100 |
101 | function getParams()
102 | {
103 | return $this->params;
104 | }
105 |
106 | function setParams($params)
107 | {
108 | $this->params = $params;
109 | }
110 |
111 | function addParam($key, $obj)
112 | {
113 | if ($this->params == null) {
114 | $this->params = array();
115 | }
116 | if ($this->APS == strtolower($key)) {
117 | throw new Exception("the key can't be aps");
118 | }
119 | $this->params[$key] = $obj;
120 | }
121 |
122 | function getAlert()
123 | {
124 | return $this->alert;
125 | }
126 |
127 | function setAlert($alert)
128 | {
129 | $this->alert = $alert;
130 | }
131 |
132 | function getBadge()
133 | {
134 | return $this->badge;
135 | }
136 |
137 | function setBadge($badge)
138 | {
139 | $this->badge = $badge;
140 | }
141 |
142 | function getSound()
143 | {
144 | return $this->sound;
145 | }
146 |
147 | function setSound($sound)
148 | {
149 | $this->sound = $sound;
150 | }
151 |
152 | function getAlertBody()
153 | {
154 | return $this->alertBody;
155 | }
156 |
157 | function setAlertBody($alertBody)
158 | {
159 | $this->alertBody = $alertBody;
160 | }
161 |
162 | function getAlertActionLocKey()
163 | {
164 | return $this->alertActionLocKey;
165 | }
166 |
167 | function setAlertActionLocKey($alertActionLocKey)
168 | {
169 | $this->alertActionLocKey = $alertActionLocKey;
170 | }
171 |
172 | function getAlertLocKey()
173 | {
174 | return $this->alertLocKey;
175 | }
176 |
177 | function setAlertLocKey($alertLocKey)
178 | {
179 | $this->alertLocKey = $alertLocKey;
180 | }
181 |
182 | function getAlertLaunchImage()
183 | {
184 | return $this->alertLaunchImage;
185 | }
186 |
187 | function setAlertLaunchImage($alertLaunchImage)
188 | {
189 | $this->alertLaunchImage = $alertLaunchImage;
190 | }
191 |
192 | function getAlertLocArgs()
193 | {
194 | return $this->alertLocArgs;
195 | }
196 |
197 | function setAlertLocArgs($alertLocArgs)
198 | {
199 | $this->alertLocArgs = $alertLocArgs;
200 | }
201 |
202 | function getContentAvailable()
203 | {
204 | return $this->contentAvailable;
205 | }
206 |
207 | function setContentAvailable($contentAvailable)
208 | {
209 | $this->contentAvailable = $contentAvailable;
210 | }
211 |
212 | function putIntoJson($key, $value, $obj)
213 | {
214 | if ($value != null) {
215 | $obj[$key] = $value;
216 | }
217 | return $obj;
218 | }
219 |
220 | function toString()
221 | {
222 | $object = array();
223 | $apsObj = array();
224 | if ($this->getAlert() != null) {
225 | $apsObj["alert"] = urlencode($this->getAlert());
226 | } else {
227 | if ($this->getAlertBody() != null || $this->getAlertLocKey() != null) {
228 | $alertObj = array();
229 | $alertObj = $this->putIntoJson("body", ($this->getAlertBody()), $alertObj);
230 | $alertObj = $this->putIntoJson("action-loc-key", ($this->getAlertActionLocKey()), $alertObj);
231 | $alertObj = $this->putIntoJson("loc-key", ($this->getAlertLocKey()), $alertObj);
232 | $alertObj = $this->putIntoJson("launch-image", ($this->getAlertLaunchImage()), $alertObj);
233 | if ($this->getAlertLocArgs() != null) {
234 | $array = array();
235 | foreach ($this->getAlertLocArgs() as $str) {
236 | array_push($array, ($str));
237 | }
238 | $alertObj["loc-args"] = $array;
239 | }
240 | $apsObj["alert"] = $alertObj;
241 | }
242 | }
243 | if ($this->getBadge() != null) {
244 | $apsObj["badge"] = $this->getBadge();
245 | }
246 | // 判断是否静音
247 | if ("com.gexin.ios.silence" != ($this->getSound())) {
248 | $apsObj = $this->putIntoJson("sound", ($this->getSound()), $apsObj);
249 | }
250 | if($this->getContentAvailable() == 1){
251 | $apsObj["content-available"]=1;
252 | }
253 | $object[$this->APS] = $apsObj;
254 | if ($this->getParams() != null) {
255 | foreach ($this->getParams() as $key => $value) {
256 | $object[($key)] = ($value);
257 | }
258 | }
259 | return Util::json_encode($object);
260 | }
261 | }
262 |
263 | class Util
264 | {
265 | static function json_encode($input){
266 | // 从 PHP 5.4.0 起, 增加了这个选项.
267 | if(defined('JSON_UNESCAPED_UNICODE')){
268 | return json_encode($input, JSON_UNESCAPED_UNICODE);
269 | }
270 | if(is_string($input)){
271 | $text = $input;
272 | $text = str_replace("\\", "\\\\", $text);
273 | //$text = str_replace('/', "\\/", $text);
274 | $text = str_replace('"', "\\".'"', $text);
275 | $text = str_replace("\b", "\\b", $text);
276 | $text = str_replace("\t", "\\t", $text);
277 | $text = str_replace("\n", "\\n", $text);
278 | $text = str_replace("\f", "\\f", $text);
279 | $text = str_replace("\r", "\\r", $text);
280 | //$text = str_replace("\u", "\\u", $text);
281 | return '"' . $text . '"';
282 | } else if(is_array($input) || is_object($input)) {
283 | $arr = array();
284 | $is_obj = is_object($input) || (array_keys($input) !== range(0, count($input) - 1));
285 | foreach($input as $k=>$v){
286 | if($is_obj){
287 | $arr[] = self::json_encode($k) . ':' . self::json_encode($v);
288 | }else{
289 | $arr[] = self::json_encode($v);
290 | }
291 | }
292 | if($is_obj){
293 | return '{' . join(',', $arr) . '}';
294 | }else{
295 | return '[' . join(',', $arr) . ']';
296 | }
297 | }else{
298 | return $input . '';
299 | }
300 | }
301 | }
--------------------------------------------------------------------------------
/getui/igetui/utils/AppConditions.php:
--------------------------------------------------------------------------------
1 | condition[] = $item;
43 | return $this;
44 | }
45 | function addCondition2($key, $values) {
46 | return $this->addCondition3($key, $values, 0);
47 | }
48 |
49 | function getCondition() {
50 | return $this->condition;
51 | }
52 | }
53 | ?>
--------------------------------------------------------------------------------
/getui/igetui/utils/GTConfig.php:
--------------------------------------------------------------------------------
1 | = 462850) {
47 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000);
48 | curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
49 | }
50 | // 通过代理访问接口需要在此处配置代理
51 | curl_setopt ($curl, CURLOPT_PROXY, GTConfig::getHttpProxyIp());
52 | curl_setopt($curl,CURLOPT_PROXYPORT,GTConfig::getHttpProxyPort());
53 | curl_setopt($curl, CURLOPT_PROXYUSERNAME, GTConfig::getHttpProxyUserName());
54 | curl_setopt($curl, CURLOPT_PROXYPASSWORD, GTConfig::getHttpProxyPasswd());
55 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return don't print
56 | curl_setopt($curl, CURLOPT_TIMEOUT, 30); //设置超时时间
57 | curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
58 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect
59 | curl_setopt($curl, CURLOPT_MAXREDIRS, 7); //HTTp定向级别
60 | //请求失败有3次重试机会
61 | $result = HttpManager::exeBySetTimes(3, $curl);
62 | //curl_close($curl);
63 | return $result;
64 | }
65 |
66 | public static function httpHead($url)
67 | {
68 | $curl = curl_init($url);
69 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
70 | curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
71 | curl_setopt($curl, CURLOPT_USERAGENT, 'GeTui PHP/1.0');
72 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD');
73 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, GTConfig::getHttpConnectionTimeOut());
74 | curl_setopt($curl, CURLOPT_TIMEOUT_MS, GTConfig::getHttpSoTimeOut());
75 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
76 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
77 | curl_setopt($curl, CURLOPT_NOBODY, 1);
78 | $header = array("Content-Type:text/html;charset=UTF-8");
79 | curl_setopt($curl, CURLOPT_HTTPHEADER,$header);
80 |
81 | $curl_version = curl_version();
82 | if ($curl_version['version_number'] >= 462850) {
83 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000);
84 | curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
85 | }
86 |
87 | //通过代理访问接口需要在此处配置代理
88 | curl_setopt ($curl, CURLOPT_PROXY, GTConfig::getHttpProxyIp());
89 | curl_setopt($curl,CURLOPT_PROXYPORT,GTConfig::getHttpProxyPort());
90 | curl_setopt($curl, CURLOPT_PROXYUSERNAME, GTConfig::getHttpProxyUserName());
91 | curl_setopt($curl, CURLOPT_PROXYPASSWORD, GTConfig::getHttpProxyPasswd());
92 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return don't print
93 | curl_setopt($curl, CURLOPT_TIMEOUT, 30); //设置超时时间
94 | curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
95 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect
96 | curl_setopt($curl, CURLOPT_MAXREDIRS, 7); //HTTp定向级别
97 | //curl_setopt($curl, CURLOPT_PROXY, '192.168.1.18:808');
98 | //请求失败有3次重试机会
99 | $result = HttpManager::exeBySetTimes(3, $curl);
100 |
101 | curl_close($curl);
102 | return $result;
103 | }
104 |
105 | public static function httpPostJson($url, $params, $gzip)
106 | {
107 | if(!isset($params["version"]))
108 | {
109 | $params["version"] = GTConfig::getSDKVersion();
110 | }
111 | $action = $params["action"];
112 | $data = json_encode($params);
113 | $result = null;
114 | try {
115 | $resp = HttpManager::httpPost($url, $data, $gzip, $action);
116 | //LogUtils::debug("发送请求 post:{$data} return:{$resp}");
117 | $result = json_decode($resp, true);
118 | return $result;
119 | } catch (GtException $gte) {
120 | throw new GtException($params["requestId"],"httpPost:[".$url."] [" .$data." ] [ ".$result."]:",$gte);
121 | } catch (Exception $e) {
122 | throw new RequestException($params["requestId"],"httpPost:[".$url."] [" .$data." ] [ ".$result."]:",$e);
123 | }
124 | }
125 |
126 | private static function exeBySetTimes($count, $curl)
127 | {
128 | $result = curl_exec($curl);
129 | $info = curl_getinfo($curl);
130 | $code = $info["http_code"];
131 |
132 | if (curl_errno($curl) != 0 && $code != 200) {
133 | LogUtils::debug("request errno: ".curl_errno($curl).",url:".$info["url"]);
134 | $count--;
135 | if ($count > 0) {
136 | $result = HttpManager::exeBySetTimes($count, $curl);
137 | } else {
138 | if ($code == 0 || $code == 404 || $code == 504){
139 | throw new GtException("connect failed, code = ".strval($code));
140 | }
141 | }
142 | }
143 | return $result;
144 | }
145 | }
--------------------------------------------------------------------------------
/getui/igetui/utils/LangUtils.php:
--------------------------------------------------------------------------------
1 | voIPPayload;
9 | if($payload == null || empty($payload)){
10 | throw new RuntimeException("payload cannot be empty");
11 | }
12 | $params = array();
13 | if($payload != null){
14 | $params["payload"] = $payload;
15 | }
16 | $params["isVoIP"] = 1;
17 | return json_encode($params);
18 | }
19 |
20 | public function setVoIPPayload($voIPPayload){
21 | $this->voIPPayload = $voIPPayload;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/getui/protobuf/encoding/pb_base128.php:
--------------------------------------------------------------------------------
1 | modus = $modus;
18 | }
19 |
20 |
21 | /**
22 | * @param $number - number as decimal
23 | * Returns the base128 value of an dec value
24 | */
25 | public function set_value($number)
26 | {
27 | $string = decbin($number);
28 | if (strlen($string) < 8)
29 | {
30 | $hexstring = dechex(bindec($string));
31 | if (strlen($hexstring) % 2 == 1)
32 | $hexstring = '0' . $hexstring;
33 | if ($this->modus == 1)
34 | {
35 | return $this->hex_to_str($hexstring);
36 | }
37 | return $hexstring;
38 | }
39 |
40 | // split it and insert the mb byte
41 | $string_array = array();
42 | $pre = '1';
43 | while (strlen($string) > 0)
44 | {
45 | if (strlen($string) < 8)
46 | {
47 | $string = substr('00000000', 0, 7 - strlen($string) % 7) . $string;
48 | $pre = '0';
49 | }
50 | $string_array[] = $pre . substr($string, strlen($string) - 7, 7);
51 | $string = substr($string, 0, strlen($string) - 7);
52 | $pre = '1';
53 | if ($string == '0000000')
54 | break;
55 | }
56 |
57 | $hexstring = '';
58 | foreach ($string_array as $string)
59 | {
60 | $hexstring .= sprintf('%02X', bindec($string));
61 | }
62 |
63 | // now format to hexstring in the right format
64 | if ($this->modus == 1)
65 | {
66 | return $this->hex_to_str($hexstring);
67 | }
68 |
69 | return $hexstring;
70 | }
71 |
72 |
73 | /**
74 | * Returns the dec value of an base128
75 | * @param string bstring
76 | */
77 | public function get_value($string)
78 | {
79 | // now just drop the msb and reorder it + parse it in own string
80 | $valuestring = '';
81 | $string_length = strlen($string);
82 |
83 | $i = 1;
84 |
85 | while ($string_length > $i)
86 | {
87 | // unset msb string and reorder it
88 | $valuestring = substr($string, $i, 7) . $valuestring;
89 | $i += 8;
90 | }
91 |
92 | // now interprete it
93 | return bindec($valuestring);
94 | }
95 |
96 | /**
97 | * Converts hex 2 ascii
98 | * @param String $hex - the hex string
99 | */
100 | public function hex_to_str($hex)
101 | {
102 | $str = '';
103 |
104 | for($i = 0; $i < strlen($hex); $i += 2)
105 | {
106 | $str .= chr(hexdec(substr($hex, $i, 2)));
107 | }
108 | return $str;
109 | }
110 |
111 | }
112 |
113 | ?>
114 |
--------------------------------------------------------------------------------
/getui/protobuf/pb_message.php:
--------------------------------------------------------------------------------
1 | reader = $reader;
62 | $this->value = $this;
63 | $this->base128 = new base128varint(PBMessage::MODUS);
64 | }
65 |
66 | /**
67 | * Get the wired_type and field_type
68 | * @param $number as decimal
69 | * @return array wired_type, field_type
70 | */
71 | public function get_types($number)
72 | {
73 | $binstring = decbin($number);
74 | $types = array();
75 | $low = substr($binstring, strlen($binstring) - 3, strlen($binstring));
76 | $high = substr($binstring,0, strlen($binstring) - 3) . '0000';
77 | $types['wired'] = bindec($low);
78 | $types['field'] = bindec($binstring) >> 3;
79 | return $types;
80 | }
81 |
82 |
83 | /**
84 | * Encodes a Message
85 | * @return string the encoded message
86 | */
87 | public function SerializeToString($rec=-1)
88 | {
89 | $string = '';
90 | // wired and type
91 | if ($rec > -1)
92 | {
93 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type);
94 | }
95 |
96 | $stringinner = '';
97 |
98 | foreach ($this->fields as $index => $field)
99 | {
100 | if (is_array($this->values[$index]) && count($this->values[$index]) > 0)
101 | {
102 | // make serialization for every array
103 | foreach ($this->values[$index] as $array)
104 | {
105 | $newstring = '';
106 | $newstring .= $array->SerializeToString($index);
107 |
108 | $stringinner .= $newstring;
109 | }
110 | }
111 | else if ($this->values[$index] != null)
112 | {
113 | // wired and type
114 | $newstring = '';
115 | $newstring .= $this->values[$index]->SerializeToString($index);
116 |
117 | $stringinner .= $newstring;
118 | }
119 | }
120 |
121 | $this->_serialize_chunk($stringinner);
122 |
123 | if ($this->wired_type == PBMessage::WIRED_LENGTH_DELIMITED && $rec > -1)
124 | {
125 | $stringinner = $this->base128->set_value(strlen($stringinner) / PBMessage::MODUS) . $stringinner;
126 | }
127 |
128 | return $string . $stringinner;
129 | }
130 |
131 | /**
132 | * Serializes the chunk
133 | * @param String $stringinner - String where to append the chunk
134 | */
135 | public function _serialize_chunk(&$stringinner)
136 | {
137 | $stringinner .= $this->chunk;
138 | }
139 |
140 | /**
141 | * Decodes a Message and Built its things
142 | *
143 | * @param message as stream of hex example '1a 03 08 96 01'
144 | */
145 | public function ParseFromString($message)
146 | {
147 | $this->reader = new PBInputStringReader($message);
148 | $this->_ParseFromArray();
149 | }
150 |
151 | /**
152 | * Internal function
153 | */
154 | public function ParseFromArray()
155 | {
156 | $this->chunk = '';
157 | // read the length byte
158 | $length = $this->reader->next();
159 | // just take the splice from this array
160 | $this->_ParseFromArray($length);
161 | }
162 |
163 | /**
164 | * Internal function
165 | */
166 | private function _ParseFromArray($length=99999999)
167 | {
168 | $_begin = $this->reader->get_pointer();
169 | while ($this->reader->get_pointer() - $_begin < $length)
170 | {
171 | $next = $this->reader->next();
172 | if ($next === false)
173 | break;
174 |
175 | // now get the message type
176 | $messtypes = $this->get_types($next);
177 |
178 | // now make method test
179 | if (!isset($this->fields[$messtypes['field']]))
180 | {
181 | // field is unknown so just ignore it
182 | // throw new Exception('Field ' . $messtypes['field'] . ' not present ');
183 | if ($messtypes['wired'] == PBMessage::WIRED_LENGTH_DELIMITED)
184 | {
185 | $consume = new PBString($this->reader);
186 | }
187 | else if ($messtypes['wired'] == PBMessage::WIRED_VARINT)
188 | {
189 | $consume = new PBInt($this->reader);
190 | }
191 | else
192 | {
193 | throw new Exception('I dont understand this wired code:' . $messtypes['wired']);
194 | }
195 |
196 | // perhaps send a warning out
197 | // @TODO SEND CHUNK WARNING
198 | $_oldpointer = $this->reader->get_pointer();
199 | $consume->ParseFromArray();
200 | // now add array from _oldpointer to pointer to the chunk array
201 | $this->chunk .= $this->reader->get_message_from($_oldpointer);
202 | continue;
203 | }
204 |
205 | // now array or not
206 | if (is_array($this->values[$messtypes['field']]))
207 | {
208 | $this->values[$messtypes['field']][] = new $this->fields[$messtypes['field']]($this->reader);
209 | $index = count($this->values[$messtypes['field']]) - 1;
210 | if ($messtypes['wired'] != $this->values[$messtypes['field']][$index]->wired_type)
211 | {
212 | throw new Exception('Expected type:' . $messtypes['wired'] . ' but had ' . $this->fields[$messtypes['field']]->wired_type);
213 | }
214 | $this->values[$messtypes['field']][$index]->ParseFromArray();
215 | }
216 | else
217 | {
218 | $this->values[$messtypes['field']] = new $this->fields[$messtypes['field']]($this->reader);
219 | if ($messtypes['wired'] != $this->values[$messtypes['field']]->wired_type)
220 | {
221 | throw new Exception('Expected type:' . $messtypes['wired'] . ' but had ' . $this->fields[$messtypes['field']]->wired_type);
222 | }
223 | $this->values[$messtypes['field']]->ParseFromArray();
224 | }
225 | }
226 | }
227 |
228 | /**
229 | * Add an array value
230 | * @param int - index of the field
231 | */
232 | protected function _add_arr_value($index)
233 | {
234 | return $this->values[$index][] = new $this->fields[$index]();
235 | }
236 |
237 | /**
238 | * Set an array value - @TODO failure check
239 | * @param int - index of the field
240 | * @param int - index of the array
241 | * @param object - the value
242 | */
243 | protected function _set_arr_value($index, $index_arr, $value)
244 | {
245 | $this->values[$index][$index_arr] = $value;
246 | }
247 |
248 | /**
249 | * Remove the last array value
250 | * @param int - index of the field
251 | */
252 | protected function _remove_last_arr_value($index)
253 | {
254 | array_pop($this->values[$index]);
255 | }
256 |
257 | /**
258 | * Set an value
259 | * @param int - index of the field
260 | * @param Mixed value
261 | */
262 | protected function _set_value($index, $value)
263 | {
264 | if (gettype($value) == 'object')
265 | {
266 | $this->values[$index] = $value;
267 | }
268 | else
269 | {
270 | $this->values[$index] = new $this->fields[$index]();
271 | $this->values[$index]->value = $value;
272 | }
273 | }
274 |
275 | /**
276 | * Get a value
277 | * @param id of the field
278 | */
279 | protected function _get_value($index)
280 | {
281 | if ($this->values[$index] == null)
282 | return null;
283 | return $this->values[$index]->value;
284 | }
285 |
286 | /**
287 | * Get array value
288 | * @param id of the field
289 | * @param value
290 | */
291 | protected function _get_arr_value($index, $value)
292 | {
293 | return $this->values[$index][$value];
294 | }
295 |
296 | /**
297 | * Get array size
298 | * @param id of the field
299 | */
300 | protected function _get_arr_size($index)
301 | {
302 | return count($this->values[$index]);
303 | }
304 |
305 | /**
306 | * Helper method for send string
307 | */
308 | protected function _save_string($ch, $string)
309 | {
310 | $this->_d_string .= $string;
311 | $content_length = strlen($this->_d_string);
312 | return strlen($string);
313 | }
314 |
315 | /**
316 | * Sends the message via post request ['message'] to the url
317 | * @param the url
318 | * @param the PBMessage class where the request should be encoded
319 | *
320 | * @return String - the return string from the request to the url
321 | */
322 | public function Send($url, &$class = null)
323 | {
324 | $ch = curl_init();
325 | $this->_d_string = '';
326 |
327 | curl_setopt($ch, CURLOPT_URL, $url);
328 | curl_setopt($ch, CURLOPT_POST, true);
329 | curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, '_save_string'));
330 | curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=' . urlencode($this->SerializeToString()));
331 | $result = curl_exec($ch);
332 |
333 | if ($class != null)
334 | $class->parseFromString($this->_d_string);
335 | return $this->_d_string;
336 | }
337 |
338 | /**
339 | * Fix Memory Leaks with Objects in PHP 5
340 | * http://paul-m-jones.com/?p=262
341 | *
342 | * thanks to cheton
343 | * http://code.google.com/p/pb4php/issues/detail?id=3&can=1
344 | */
345 | public function _destruct()
346 | {
347 | if (isset($this->reader))
348 | {
349 | unset($this->reader);
350 | }
351 | if (isset($this->value))
352 | {
353 | unset($this->value);
354 | }
355 | // base128
356 | if (isset($this->base128))
357 | {
358 | unset($this->base128);
359 | }
360 | // fields
361 | if (isset($this->fields))
362 | {
363 | foreach ($this->fields as $name => $value)
364 | {
365 | unset($this->$name);
366 | }
367 | unset($this->fields);
368 | }
369 | // values
370 | if (isset($this->values))
371 | {
372 | foreach ($this->values as $name => $value)
373 | {
374 | if (is_array($value))
375 | {
376 | foreach ($value as $name2 => $value2)
377 | {
378 | if (is_object($value2) AND method_exists($value2, '__destruct'))
379 | {
380 | $value2->__destruct();
381 | }
382 | unset($value2);
383 | }
384 | if (isset($name2))
385 | unset($value->$name2);
386 | }
387 | else
388 | {
389 | if (is_object($value) AND method_exists($value, '__destruct'))
390 | {
391 | $value->__destruct();
392 | }
393 | unset($value);
394 | }
395 | unset($this->values->$name);
396 | }
397 | unset($this->values);
398 | }
399 | }
400 |
401 | }
402 | ?>
403 |
--------------------------------------------------------------------------------
/getui/protobuf/reader/pb_input_reader.php:
--------------------------------------------------------------------------------
1 | base128 = new base128varint(1);
15 | }
16 |
17 | /**
18 | * Gets the acutal position of the point
19 | * @return int the pointer
20 | */
21 | public function get_pointer()
22 | {
23 | return $this->pointer;
24 | }
25 |
26 | /**
27 | * Add add to the pointer
28 | * @param int $add - int to add to the pointer
29 | */
30 | public function add_pointer($add)
31 | {
32 | $this->pointer += $add;
33 | }
34 |
35 | /**
36 | * Get the message from from to actual pointer
37 | * @param from
38 | */
39 | public function get_message_from($from)
40 | {
41 | return substr($this->string, $from, $this->pointer - $from);
42 | }
43 |
44 | /**
45 | * Getting the next varint as decimal number
46 | * @return varint
47 | */
48 | public abstract function next();
49 | }
50 | ?>
51 |
--------------------------------------------------------------------------------
/getui/protobuf/reader/pb_input_string_reader.php:
--------------------------------------------------------------------------------
1 | string = $string;
13 | $this->length = strlen($string);
14 | }
15 |
16 | /**
17 | * get the next
18 | * @param boolean $is_string - if set to true only one byte is read
19 | */
20 | public function next($is_string = false)
21 | {
22 | $package = '';
23 | while (true)
24 | {
25 | if ($this->pointer >= $this->length)
26 | {
27 | return false;
28 | }
29 |
30 | $string = '';
31 | $string = $this->string[$this->pointer];
32 | $this->pointer++;
33 |
34 | if ($is_string == true)
35 | return ord($string);
36 |
37 | $value = decbin(ord($string));
38 |
39 | if ($value >= 10000000 && $is_string == false)
40 | {
41 | // now fill to eight with 00
42 | $package .= $value;
43 | }
44 | else
45 | {
46 | // now fill to length of eight with 0
47 | $value = substr('00000000', 0, 8 - strlen($value) % 8) . $value;
48 | return $this->base128->get_value($package . $value);
49 | }
50 | }
51 | }
52 | }
53 | ?>
54 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_bool.php:
--------------------------------------------------------------------------------
1 | value = $this->reader->next();
17 | $this->value = ($this->value != 0) ? 1 : 0;
18 | }
19 |
20 | }
21 | ?>
22 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_bytes.php:
--------------------------------------------------------------------------------
1 | value = '';
17 | // first byte is length
18 | $length = $this->reader->next();
19 |
20 | // just extract the string
21 | $pointer = $this->reader->get_pointer();
22 | $this->reader->add_pointer($length);
23 | $this->value = $this->reader->get_message_from($pointer);
24 | }
25 |
26 | /**
27 | * Serializes type
28 | */
29 | public function SerializeToString($rec = -1)
30 | {
31 | $string = '';
32 |
33 | if ($rec > -1)
34 | {
35 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type);
36 | }
37 |
38 | $string .= $this->base128->set_value(strlen($this->value));
39 | $string .= $this->value;
40 |
41 | return $string;
42 | }
43 | }
44 | ?>
45 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_enum.php:
--------------------------------------------------------------------------------
1 | value = $this->reader->next();
17 | }
18 |
19 | /**
20 | * Serializes type
21 | */
22 | public function SerializeToString($rec=-1)
23 | {
24 | $string = '';
25 |
26 | if ($rec > -1)
27 | {
28 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type);
29 | }
30 |
31 | $value = $this->base128->set_value($this->value);
32 | $string .= $value;
33 |
34 | return $string;
35 | }
36 | }
37 | ?>
38 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_int.php:
--------------------------------------------------------------------------------
1 | value = $this->reader->next();
17 | }
18 |
19 | /**
20 | * Serializes type
21 | */
22 | public function SerializeToString($rec=-1)
23 | {
24 | // first byte is length byte
25 | $string = '';
26 |
27 | if ($rec > -1)
28 | {
29 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type);
30 | }
31 |
32 | $value = $this->base128->set_value($this->value);
33 | $string .= $value;
34 |
35 | return $string;
36 | }
37 | }
38 | ?>
39 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_scalar.php:
--------------------------------------------------------------------------------
1 | value = $value;
13 | }
14 |
15 | /**
16 | * Get the scalar value
17 | */
18 | public function get_value()
19 | {
20 | return $this->value;
21 | }
22 | }
23 | ?>
24 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_signed_int.php:
--------------------------------------------------------------------------------
1 | value;
19 | $this->value = round($this->value / 2);
20 | if ($saved % 2 == 1)
21 | {
22 | $this->value = -($this->value);
23 | }
24 | }
25 |
26 | /**
27 | * Serializes type
28 | */
29 | public function SerializeToString($rec=-1)
30 | {
31 | // now convert signed int to int
32 | $save = $this->value;
33 | if ($this->value < 0)
34 | {
35 | $this->value = abs($this->value)*2-1;
36 | }
37 | else
38 | {
39 | $this->value = $this->value*2;
40 | }
41 | $string = parent::SerializeToString($rec);
42 | // restore value
43 | $this->value = $save;
44 |
45 | return $string;
46 | }
47 | }
48 | ?>
49 |
--------------------------------------------------------------------------------
/getui/protobuf/type/pb_string.php:
--------------------------------------------------------------------------------
1 | value = '';
17 | // first byte is length
18 | $length = $this->reader->next();
19 |
20 | // just extract the string
21 | $pointer = $this->reader->get_pointer();
22 | $this->reader->add_pointer($length);
23 | $this->value = $this->reader->get_message_from($pointer);
24 | }
25 |
26 | /**
27 | * Serializes type
28 | */
29 | public function SerializeToString($rec = -1)
30 | {
31 | $string = '';
32 |
33 | if ($rec > -1)
34 | {
35 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type);
36 | }
37 |
38 | $string .= $this->base128->set_value(strlen($this->value));
39 | $string .= $this->value;
40 |
41 | return $string;
42 | }
43 | }
44 | ?>
45 |
--------------------------------------------------------------------------------
/src/Constants/TemplateConstants.php:
--------------------------------------------------------------------------------
1 | 'getTransmissionTemplate',
9 | 'notification' => 'getNotificationTemplate',
10 | 'link' => 'getLinkTemplate',
11 | 'startactivity' => 'getStartActivityTemplate',
12 | 'revoke' => 'getRevokeTemplate',
13 | 'notypopload' => 'getNotyPopLoadTemplate'
14 | ];
15 | }
16 |
--------------------------------------------------------------------------------
/src/Facade/Getui.php:
--------------------------------------------------------------------------------
1 | gt_appid = $config['appid'];
63 | $this->gt_appkey = $config['appkey'];
64 | $this->gt_appsecret = $config['appsecret'];
65 | $this->gt_mastersecret = $config['mastersecret'];
66 | $this->instance = new IGeTui(static::HOST, $this->gt_appkey, $this->gt_mastersecret);
67 | }
68 |
69 | /**
70 | * 推送模版
71 | * 推送效果设置分为通知样式设置和后续操作设置
72 | * 通知样式:响铃 震动 通知是否可清除
73 | * 后续操作:打开应用首页 打开应用内指定页面 打开浏览器指定网页
74 | * @param string $type
75 | * @param array $data
76 | * @return mixed
77 | * @throws Exception
78 | */
79 | private function getTemplate(string $type = NULL, array $data = [])
80 | {
81 | return $this->getTemplateByType($type, $data);
82 | }
83 |
84 | /**
85 | * 进阶功能
86 | * 1.消息撤回
87 | * 2.消息覆盖
88 | * 3.短信补量 需要短信
89 | * 4.多厂商推送
90 | */
91 |
92 | /**
93 | * 统计API
94 | * 提供开发者获取推送数据接口 便于开发者整合到自己推送系统中
95 | * 1.推送结果查询
96 | * 2.用户统计数据查询
97 | * 3.用户画像数据查询
98 | */
99 |
100 | /**
101 | * 用户API
102 | * 个推 支持多种方式管理用户
103 | * 1.别名 开发者自定的的用户表示
104 | * 2.标签 用户特定属性
105 | * 3.黑名单 黑名单用户无法收到推送
106 | */
107 |
108 | /**
109 | * 推送API:
110 | * 1.toSingle 单推 向单个用户推送消息
111 | * 2.toList 批量推 向指定的用户推送消息
112 | * 3.toApp 群推 向APP符合筛选条件的所有用户推送消息 支持定速推送/定时推送/支持条件的交并补功能
113 | */
114 |
115 | /**
116 | * 单推
117 | * @param int $type
118 | * @param array $data
119 | * @return array
120 | * @throws Exception
121 | */
122 | public function pushToSingle($type = 1, $data = [])
123 | {
124 | $fields = ['network_type', 'client_id'];
125 | $this->validateFields($fields, $data);
126 |
127 | // 1.选择通知模板
128 | $template = $this->getTemplate($type, $data);
129 | // 个推信息体
130 | $message = new IGtSingleMessage();
131 | $message->set_isOffline(true);//是否离线
132 | $time = isset($data['offline_expire_time']) ? $data['offline_expire_time'] : 3600 * 12 * 1000;
133 | $message->set_offlineExpireTime($time);//离线时间
134 | $message->set_data($template);//设置推送消息类型
135 | $message->set_PushNetWorkType($data['network_type']);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
136 | //接收方
137 | $target = new IGtTarget();
138 | $target->set_appId($this->gt_appid);
139 | $target->set_clientId($data['client_id']);
140 |
141 | try {
142 | $response = $this->instance->pushMessageToSingle($message, $target);
143 | return $response;
144 | } catch (RequestException $e) {
145 | $requstId = $e->getRequestId();
146 | $response = $this->instance->pushMessageToSingle($message, $target, $requstId);
147 | return $response;
148 | }
149 | }
150 |
151 | /**
152 | * 批量推送
153 | * @param string $type
154 | * @param array $data
155 | * @return bool
156 | * @throws Exception
157 | */
158 | public function pushToList(string $type = NULL, array $data = [])
159 | {
160 | $fields = ['client_id_list', 'network_type'];
161 | $this->validateFields($fields, $data);
162 |
163 | $template = $this->getTemplate($type, $data);
164 |
165 | $message = new IGtListMessage();
166 | $message->set_data($template);
167 | $isOffLine = isset($data['is_offline']) ? $data['is_offline'] : true;
168 | $message->set_isOffline($isOffLine);
169 | $time = isset($data['offline_expire_time']) ? $data['offline_expire_time'] : 3600*12*1000;
170 | $message->set_offlineExpireTime($time);
171 | $message->set_pushNetWorkType($data['network_type']);
172 |
173 | // 1.获取taskId
174 | $contentId = $this->instance->getContentId($message);
175 |
176 | // 2.构建消息目标列表
177 | $targetList = [];
178 | foreach ($data['client_id_list'] as $clientId) {
179 | $target = new IGtTarget();
180 | $target->set_appId($this->gt_appid);
181 | $target->set_clientId($clientId);
182 | $targetList[] = $target;
183 | }
184 |
185 | // 3.批量推送
186 | $response = $this->instance->pushMessageToList($contentId, $targetList);
187 | return $response;
188 | }
189 |
190 | /**
191 | * todo iOS
192 | * 批量单推
193 | */
194 | public function pushMessageToSingleBatch(array $data = [])
195 | {
196 | // 创建批次处理对象
197 | $batch = new \IGtBatch();
198 | $batch->setApiUrl(self::HOST);
199 |
200 | // 创建消息
201 | }
202 |
203 | /**
204 | * 推送给APP done
205 | * @param string $type
206 | * @param array $data
207 | * @return mixed|null
208 | * @throws Exception
209 | */
210 | public function pushToApp(string $type = NULL, array $data = [])
211 | {
212 | // 消息模板
213 | $template = $this->getTemplate($type, $data);
214 |
215 | // 定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
216 | $message = new IGtAppMessage();
217 | // 定速推送
218 | if (isset($data['speed'])) {
219 | $message->set_speed($data['speed']);
220 | }
221 | $message->set_isOffline(true);
222 | $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
223 | $message->set_data($template);
224 |
225 | $appIdList=array($this->gt_appid);
226 | $phoneTypeList=array('ANDROID');
227 | $provinceList=array('浙江');
228 | $tagList=array('haha');
229 |
230 | $message->set_appIdList($appIdList);
231 |
232 | //$message->set_conditions($cdt->getCondition());
233 | // STEP6:执行推送
234 | $response = $this->instance->pushMessageToApp($message,"task1");
235 | return $response;
236 | }
237 |
238 | /**
239 | * 获取消息的taskid
240 | * @param null $message
241 | * @return mixed
242 | */
243 | public function getTaskId($message = null)
244 | {
245 | return $this->instance->getContentId($message);
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/src/GetuiServiceProvider.php:
--------------------------------------------------------------------------------
1 | app instanceof LaravelApplication && $this->app->runningInConsole()) {
19 | $this->publishes([$source => config_path('getui.php')]);
20 | } elseif ($this->app instanceof LumenApplication) {
21 | $this->app->configure('getui');
22 | }
23 |
24 | $this->mergeConfigFrom($source, 'getui');
25 | }
26 |
27 | /**
28 | * 注册单例
29 | */
30 | public function register()
31 | {
32 | $this->app->singleton(GetuiService::class, function ($app) {
33 | return new GetuiService($app->config->get('getui', []));
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/TestController.php:
--------------------------------------------------------------------------------
1 | transmission();
19 | }
20 |
21 | private function transmission()
22 | {
23 | // 1.单推
24 | // $this->transmissionSingle();
25 | // 2.多推
26 | // $this->transmissionList();
27 | // 3.全量推
28 | // $this->transmissionApp();
29 | // 4.自定义消息
30 | $this->transmissionCustom();
31 | }
32 |
33 | /**
34 | * 自定义消息-透传模板
35 | */
36 | private function transmissionCustom()
37 | {
38 | $content = '自定义消息文本1243';
39 | $custom = [
40 | 'keyId' => 1,
41 | 'keyType' => 111199,
42 | 'msg' => $content
43 | ];
44 | $data = [
45 | 'title' => '自定义消息标题-122',
46 | 'transmission_type' => 2,
47 | 'function' => 'json_encode',
48 | 'content' => $content,
49 | 'custom_data' => $custom,
50 | 'custom_fields' => [
51 | 'keyId', 'keyType'
52 | ],
53 | 'speed' => 10 // 此处表示推送时设置定速推送且 100条/秒
54 | ];
55 | // // 自定义数据
56 | // $content = [
57 | // 'keyId' => 1,
58 | // 'keyType' => 111199
59 | // ];
60 | // $data = [
61 | // 'title' => '自定义消息iOS',
62 | // 'network_type' => 0,
63 | // 'transmission_type' => 2,
64 | //// 'client_id' => '249c93193d9a0734dcb62a7029b383cf',
65 | // 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
66 | // 'content' => json_encode($content) // 自定义数据加密 接收端需要按照同样方式解密
67 | // ];
68 |
69 | Getui::pushToSingle('transmission', $data);
70 | Getui::pushToApp('transmission', $data);
71 | }
72 |
73 | /**
74 | * 透传消息 单推
75 | */
76 | private function transmissionSingle()
77 | {
78 | $data = [
79 | 'network_type' => 0,
80 | 'transmission_type' => 2,
81 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
82 | 'content' => '透传内容-单推1'
83 | ];
84 | Getui::pushToSingle('transmission', $data);
85 | }
86 |
87 | /**
88 | * 透传消息-全量
89 | */
90 | private function transmissionApp()
91 | {
92 | $data = [
93 | 'transmission_type' => 2,
94 | 'content' => '透传内容-全量6'
95 | ];
96 | $res = Getui::pushToApp('transmission', $data);
97 | }
98 |
99 | /**
100 | * 透传消息-多推
101 | */
102 | private function transmissionList()
103 | {
104 | $data = [
105 | 'network_type' => 0,
106 | 'transmission_type' => 2,
107 | 'client_id_list' => [
108 | 'c3024643a24c11bd3762d437c9103a42'
109 | ],
110 | 'content' => '透传内容-多推1'
111 | ];
112 | Getui::pushToList('transmission', $data);
113 | }
114 |
115 |
116 | /**
117 | * 多推测试
118 | */
119 | private function pushtoList()
120 | {
121 | // 1.通知模板-打开应用首页
122 | // $this->notificationList();
123 | // 2.通知模板-打开连接
124 | $this->linkList();
125 | }
126 |
127 | /**
128 | * // 1.通知模板-打开应用首页
129 | */
130 | private function notificationList()
131 | {
132 | $data = [
133 | 'client_id_list' => [
134 | 'c3024643a24c11bd3762d437c9103a42',
135 | ],
136 | 'network_type' => 0,
137 | 'content' => '多推内容',
138 | 'title' => '多推标题',
139 | 'text' => '多推文本',
140 | 'is_ring' => true,
141 | 'is_vibrate' => true,
142 | 'logo' => '',
143 | 'logo_url' => ''
144 | ];
145 |
146 | Getui::pushToList('notification', $data);
147 | }
148 |
149 | /**
150 | * 2.通知模板-打开连接
151 | */
152 | private function linkList()
153 | {
154 | $data = [
155 | 'client_id_list' => [
156 | 'c3024643a24c11bd3762d437c9103a42',
157 | ],
158 | 'network_type' => 0,
159 | 'title' => '多推连接标题',
160 | 'text' => '多推连接文本',
161 | 'is_ring' => true,
162 | 'is_vibrate' => true,
163 | 'is_clearable' => true,
164 | 'url' => 'https://www.baidu.com'
165 | ];
166 |
167 | Getui::pushToList('link', $data);
168 | }
169 |
170 | /**
171 | * 单推测试
172 | */
173 | private function pushtoSingle()
174 | {
175 | // 1.单推-打开链接
176 | // $this->linkSingle();
177 | // 2.单推-打开应用首页
178 | $this->notificationSingle();
179 |
180 | }
181 |
182 | /**
183 | * // 2.单推-打开应用首页
184 | */
185 | private function notificationSingle()
186 | {
187 | $data = [
188 | 'network_type' => 0,
189 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
190 | 'content' => '单人推送内容',
191 | 'title' => '单人推送标题',
192 | 'text' => '单人推送文本',
193 | 'is_ring' => true,
194 | 'is_vibrate' => true,
195 | 'logo' => '',
196 | 'logo_url' => ''
197 | ];
198 |
199 | Getui::pushToSingle('notification', $data);
200 | }
201 |
202 | /**
203 | * / 1.单推-打开链接
204 | */
205 | private function linkSingle()
206 | {
207 | $data = [
208 | 'title' => '测试推送',
209 | 'text' => '哈哈哈',
210 | 'content' => '内容',
211 | 'is_ring' => true,
212 | 'is_vibrate' => true,
213 | 'is_clearable' => true,
214 | 'url' => 'http://www.juejin.im',
215 | 'client_id' => 'c3024643a24c11bd3762d437c9103a42',
216 | 'network_type' => 0
217 | ];
218 |
219 | Getui::pushToSingle('link', $data);
220 | }
221 |
222 | /**
223 | * 全量推送
224 | */
225 | private function pushtoapp()
226 | {
227 | // 全量推送-通知模板 打开连接
228 | $this->linkApp();
229 | $this->notificationApp();
230 | }
231 |
232 |
233 | /**
234 | * 全量推送-通知模板 打开连接
235 | */
236 | private function linkApp()
237 | {
238 | $data = [
239 | 'title' => '网页推送',
240 | 'text' => '网页推送文本',
241 | 'is_ring' => true,
242 | 'is_vibrate' => true,
243 | 'url' => 'http://www.baidu.com',
244 | 'is_clearable' => true
245 | ];
246 |
247 | Getui::pushToApp('link', $data);
248 | }
249 |
250 | /**
251 | * 全量推送-通知模板 打开首页
252 | */
253 | private function notificationApp()
254 | {
255 | $data = [
256 | 'title' => '测试推送12111',
257 | 'text' => '哈哈哈1',
258 | 'content' => '内容511121322',
259 | 'is_ring' => true,
260 | 'is_vibrate' => true,
261 | 'logo' => '',
262 | 'logo_url' => 'http://wwww.igetui.com/logo.png'
263 | ];
264 |
265 | Getui::pushToApp('notification', $data);
266 | }
267 | }
268 |
--------------------------------------------------------------------------------
/src/Traits/TemplateTrait.php:
--------------------------------------------------------------------------------
1 | $method($params);
38 | }
39 |
40 | throw new \Exception('消息模板不存在!');
41 | }
42 |
43 | /**
44 | * 【通知模板】通知弹框下载功能模板
45 | * @param array $data
46 | * @return IGtNotyPopLoadTemplate
47 | * @throws \Exception
48 | */
49 | private function getNotyPopLoadTemplate(array $data = [])
50 | {
51 | $template = new IGtNotyPopLoadTemplate();
52 |
53 | $template->set_notifyId($data['notify_id']);
54 | $template ->set_appId($this->gt_appid);//应用appid
55 | $template ->set_appkey($this->gt_appkey);//应用appkey
56 | //通知栏
57 | $template ->set_notyTitle($data['notify_title']);//通知栏标题
58 | $template ->set_notyContent($data['notify_content']);//通知栏内容
59 | $template ->set_notyIcon($data['notify_icon']);//通知栏logo
60 | $template ->set_isBelled($data['is_belled']);//是否响铃
61 | $template ->set_isVibrationed($data['is_vibrationed']);//是否震动
62 | $template ->set_isCleared($data['is_cleared']);//通知栏是否可清除
63 | //弹框
64 | $template ->set_popTitle($data['pop_title']);//弹框标题
65 | $template ->set_popContent($data['pop_content']);//弹框内容
66 | $template ->set_popImage($data['pop_image']);//弹框图片
67 | $template ->set_popButton1($data['pop_button_left']);//左键
68 | $template ->set_popButton2($data['pop_buton_right']);//右键
69 | //下载
70 | $template ->set_loadIcon($data['load_icon']);//弹框图片
71 | $template ->set_loadTitle($data['load_title']);
72 | $template ->set_loadUrl($data['load_url']);
73 | $template ->set_isAutoInstall($data['is_auto_install']);
74 | $template ->set_isActived($data['is_actived']);
75 | $template->set_channel($data['channel']);
76 | $template->set_channelName($data['channel_name']);
77 | $template->set_channelLevel($data['channel_level']);
78 | //$template->set_notifyStyle(0);
79 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
80 | return $template;
81 | }
82 |
83 | /**
84 | * 【透传模板】自定义消息
85 | * @param array $data
86 | * @return IGtTransmissionTemplate
87 | * @throws \Exception
88 | */
89 | private function getTransmissionTemplate(array $data = [])
90 | {
91 | $fields = ['transmission_type', 'content', 'title', 'custom_data', 'custom_fields'];
92 | $this->validateFields($fields, $data);
93 | $template = new IGtTransmissionTemplate();
94 | //应用appid
95 | $template->set_appId($this->gt_appid);
96 | //应用appkey
97 | $template->set_appkey($this->gt_appkey);
98 | //透传消息类型
99 | $template->set_transmissionType($data['transmission_type']);
100 | $transContent = $data['custom_data'];
101 | if (isset($data['function'])) {
102 | $method = $data['function'];
103 | if (function_exists($method)) {
104 | $transContent = $method($data['custom_data']);
105 | } else {
106 | throw new \Exception('自定义消息加密函数' . $method . '不存在!');
107 | }
108 | }
109 | //透传内容
110 | $template->set_transmissionContent($transContent);
111 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
112 |
113 | // iOS推送必要设置
114 | $apn = $this->setIOSPushInfo($data['content'], $data['title'], $transContent, $data['custom_fields'], $data['custom_data']);
115 | $template->set_apnInfo($apn);
116 | // 透传对接通知
117 | if (isset($data['is_notify']) && $data['is_notify'] && !empty($data['notify_params'])) {
118 | $notifyParams = $data['notify_params'];
119 | $fields = ['notify_type', 'notify_url', 'notify_intent'];
120 | $this->validateFields($fields, $notifyParams);
121 | $notify = new IGtNotify();
122 | $notify->set_title($data['title']);
123 | $notify->set_content($data['content']);
124 | if ($notifyParams['notify_type'] == 'intent') {
125 | $notify->set_type(\NotifyInfo_Type::_intent);
126 | $notify->set_intent($notifyParams['notify_intent']);
127 | } else if ($notifyParams['notify_type'] == 'url') {
128 | $notify->set_type(\NotifyInfo_Type::_url);
129 | $notify->set_url($notifyParams['notify_url']);
130 | } else {
131 | throw new \Exception("透传--通知类型不正确!请传入intent/url中的一种!");
132 | }
133 | $template->set3rdNotifyInfo($notify);
134 | }
135 | return $template;
136 | }
137 |
138 | /**
139 | * 【通知模板】 打开应用首页
140 | * @param array $data
141 | * @return IGtNotificationTemplate
142 | * @throws \Exception
143 | */
144 | private function getNotificationTemplate(array $data = [])
145 | {
146 | $fields = ['content', 'title', 'text', 'is_ring', 'is_vibrate', 'logo', 'logo_url'];
147 | $this->validateFields($fields, $data);
148 |
149 | $template = new IGtNotificationTemplate();
150 | $template->set_appId($this->gt_appid); //应用appid
151 | $template->set_appkey($this->gt_appkey); //应用appkey
152 | $template->set_transmissionType(1);//透传消息类型
153 | $template->set_transmissionContent($data['content']);//透传内容
154 | $template->set_title($data['title']); //通知栏标题
155 | $template->set_text($data['text']); //通知栏内容
156 | $template->set_logo($data['logo']); //通知栏logo
157 | $template->set_logoURL($data['logo_url']); //通知栏logo链接
158 | $template->set_isRing($data['is_ring']); //是否响铃
159 | $template->set_isVibrate($data['is_vibrate']); //是否震动
160 | $template->set_isClearable(true); //通知栏是否可清除
161 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
162 | // $template->set_channel($data['channel']);
163 | // $template->set_channelName($data['channel_name']);
164 | // $template->set_channelLevel($data['channel_level']);
165 | // $template->set_notifyId($data['notify_id']);
166 | return $template;
167 | }
168 |
169 | /**
170 | * 【通知模板】 打开浏览器网页
171 | * @param array $data
172 | * @return IGtLinkTemplate
173 | * @throws \Exception
174 | */
175 | private function getLinkTemplate(array $data = [])
176 | {
177 | $fields = ['title', 'text', 'is_ring', 'is_vibrate', 'is_clearable', 'url'];
178 | $this->validateFields($fields, $data);
179 | $template = new IGtLinkTemplate();
180 | $template->set_appId($this->gt_appid); //应用appid
181 | $template->set_appkey($this->gt_appkey); //应用appkey
182 | $template->set_title($data['title']); //通知栏标题
183 | $template->set_text($data['text']); //通知栏内容
184 | $template->set_logo(""); //通知栏logo
185 | $template->set_logoURL(""); //通知栏logo链接
186 | $template->set_isRing($data['is_ring']); //是否响铃
187 | $template->set_isVibrate($data['is_vibrate']); //是否震动
188 | $template->set_isClearable($data['is_clearable']); //通知栏是否可清除
189 | $template->set_url($data['url']); //打开连接地址
190 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
191 | $template->set_channel('set_channel');
192 | $template->set_channelName('channel_name');
193 | $template->set_channelLevel(3);
194 | $template->set_notifyId(12345678);
195 |
196 | return $template;
197 | }
198 |
199 | /**
200 | * iOS推送必要设置
201 | * @param string $content
202 | * @param string $title
203 | * @param string $transContent
204 | * @param array $customFields
205 | * @param array $customData
206 | * @return IGtAPNPayload
207 | * @throws \Exception
208 | */
209 | private function setIOSPushInfo($content = '', $title = '', $transContent = '', $customFields = [], $customData = [])
210 | {
211 | //APN高级推送
212 | $apn = new \IGtAPNPayload();
213 | $alertmsg = new \DictionaryAlertMsg();
214 | $alertmsg->body = $content;
215 | $alertmsg->actionLocKey = "ActionLockey";
216 | // $alertmsg->locKey = "LocKey";
217 | $alertmsg->locArgs = array("locargs");
218 | $alertmsg->launchImage = "launchimage";
219 | // IOS8.2 支持
220 | $alertmsg->title = $title;
221 | // $alertmsg->titleLocKey = "TitleLocKey";
222 | $alertmsg->titleLocArgs = array("TitleLocArg");
223 |
224 | $apn->alertMsg = $alertmsg;
225 | $apn->badge = 1;
226 | $apn->sound = "";
227 |
228 | $apn->add_customMsg("payload", $transContent);
229 | // APN透传消息添加自定义字段
230 | foreach ($customFields as $customField) {
231 | if (is_null($customData[$customField])) {
232 | throw new \Exception('APN透传字段' . $customField . '为空');
233 | }
234 | $apn->add_customMsg($customField, $customData[$customField]);
235 | }
236 | $apn->contentAvailable = 1;
237 | $apn->category = "ACTIONABLE";
238 | return $apn;
239 | }
240 |
241 | /**
242 | * 【通知模板】 打开应用内页面
243 | * @param array $data
244 | * @return IGtStartActivityTemplate
245 | * @throws \Exception
246 | */
247 | private function getStartActivityTemplate(array $data = [])
248 | {
249 | $template = new IGtStartActivityTemplate();
250 | $template->set_appId($data['appid']);//应用appid
251 | $template->set_appkey($data['appkey']);//应用appkey
252 | $template->set_intent($data['indent']);
253 | $template->set_title($data['title']);//通知栏标题
254 | $template->set_text($data['text']);//通知栏内容
255 | $template->set_logo($data['logo']);//通知栏logo
256 | $template->set_logoURL($data['logo_url']);
257 | $template->set_isRing($data['is_ring']);//是否响铃
258 | $template->set_isVibrate($data['is_vibrate']);//是否震动
259 | $template->set_isClearable($data['is_clearable']);//通知栏是否可清除
260 | $template->set_duration($data['start'],$data['end']);
261 | $smsMessage = new SmsMessage();//设置短信通知
262 | $smsMessage->setPayload("1234");
263 | $smsMessage->setUrl("http://www/getui");
264 | $smsMessage->setSmsTemplateId($data['sms_template_id']);
265 | $smsMessage->setOfflineSendtime(1000);
266 | $smsMessage->setIsApplink(true);
267 | $template->setSmsInfo($smsMessage);
268 | $template->set_notifyId($data['notify_id']);
269 | return $template;
270 | }
271 |
272 | /**
273 | * 【通知模板】通知消息撤回
274 | * @param array $data 传入数据
275 | * @return IGtRevokeTemplate
276 | */
277 | private function getRevokeTemplate(array $data = [])
278 | {
279 | $revoke = new IGtRevokeTemplate();
280 | $revoke->set_appId($data['appid']);
281 | $revoke->set_appkey($data['appkey']);
282 | $revoke->set_oldTaskId($data['taskId']);
283 | $revoke->set_force(false);
284 | return $revoke;
285 | }
286 | }
287 |
--------------------------------------------------------------------------------
/src/Traits/ValidateTrait.php:
--------------------------------------------------------------------------------
1 | [
5 | 'appid' => 'V7Qa7xyQuRA1kZvHazb177',
6 | 'appkey' => 'OwAho8r78bA84vfTi3vfI1',
7 | 'appsecret' => 'SwXRmcWjk18vpYZDtu6n5',
8 | 'mastersecret' => 'o0UIaJzF4s80N41D63CDEA'
9 | ],
10 | ];
11 |
12 |
--------------------------------------------------------------------------------