├── GTBaseApi.php ├── GTClient.php ├── GTPushApi.php ├── GTStatisticsApi.php ├── GTUserApi.php ├── LICENSE ├── README.md ├── composer.json ├── exception └── GTException.php ├── request ├── GTApiRequest.php ├── auth │ └── GTAuthRequest.php ├── push │ ├── GTAudienceRequest.php │ ├── GTCondition.php │ ├── GTNotification.php │ ├── GTPushBatchRequest.php │ ├── GTPushChannel.php │ ├── GTPushMessage.php │ ├── GTPushRequest.php │ ├── GTRevoke.php │ ├── GTSettings.php │ ├── GTStrategy.php │ ├── android │ │ ├── GTAndroid.php │ │ ├── GTThirdNotification.php │ │ └── GTUps.php │ └── ios │ │ ├── GTAlert.php │ │ ├── GTAps.php │ │ ├── GTIos.php │ │ └── GTMultimedia.php └── user │ ├── GTAliasRequest.php │ ├── GTBadgeSetRequest.php │ ├── GTCidAlias.php │ ├── GTTagBatchSetRequest.php │ ├── GTTagSetRequest.php │ └── GTUserQueryRequest.php ├── test ├── PushApiTest.php ├── StatisticsApiTest.php └── UserApiTest.php └── utils ├── GTConfig.php └── GTHttpManager.php /GTBaseApi.php: -------------------------------------------------------------------------------- 1 | httpRequest($api, $params, GTHttpManager::HTTP_METHOD_POST); 10 | } 11 | 12 | protected function put($api, $params) 13 | { 14 | return $this->httpRequest($api, $params, GTHttpManager::HTTP_METHOD_PUT); 15 | } 16 | 17 | protected function get($api, $params) 18 | { 19 | return $this->httpRequest($api, $params, GTHttpManager::HTTP_METHOD_GET); 20 | } 21 | 22 | protected function delete($api, $params) 23 | { 24 | return $this->httpRequest($api, $params, GTHttpManager::HTTP_METHOD_DELETE); 25 | } 26 | 27 | private function httpRequest($api, $params, $method, $gzip = false) 28 | { 29 | try { 30 | $rep = GTHttpManager::httpRequest($this->getUrl($api), $params, $this->buildHead(), $gzip, $method); 31 | } catch (GTException $e) { 32 | throw $e; 33 | } 34 | if ($rep != null) { 35 | if ('10001' == $rep['code']) { 36 | try { 37 | if ($this->gtClient->auth()) { 38 | $rep = GTHttpManager::httpRequest($this->getUrl($api), $params, $this->buildHead(), $gzip, $method); 39 | } 40 | } catch (GTException $e) { 41 | throw $e; 42 | } 43 | } else if ('301' == $rep['code']) { 44 | if (empty($rep["data"]) || empty($rep["data"]["host_list"]) || empty($rep["data"]["host_list"][0]["domain_list"])) { 45 | throw new GTException("域名错误"); 46 | } 47 | $this->gtClient->setDomainUrlList($rep["data"]["host_list"][0]["domain_list"]); 48 | try { 49 | $rep = GTHttpManager::httpRequest($this->getUrl($api), $params, $this->buildHead(), $gzip, $method); 50 | } catch (GTException $e) { 51 | throw $e; 52 | } 53 | } 54 | } 55 | return $rep; 56 | } 57 | 58 | private function analysisUrlList() 59 | { 60 | 61 | } 62 | 63 | private function buildHead() 64 | { 65 | $headers = array(); 66 | if ($this->gtClient->getAuthToken() != null) { 67 | array_push($headers, "token:" . $this->gtClient->getAuthToken()); 68 | } 69 | return $headers; 70 | } 71 | 72 | private function getUrl($api) 73 | { 74 | return $this->gtClient->getHost() . "/v2/" . $this->gtClient->getAppId() . $api; 75 | } 76 | } -------------------------------------------------------------------------------- /GTClient.php: -------------------------------------------------------------------------------- 1 | appkey = $appkey; 70 | $this->masterSecret = $masterSecret; 71 | $this->appId = $appId; 72 | $this->pushApi = new GTPushApi($this); 73 | $this->statisticsApi = new GTStatisticsApi($this); 74 | $this->userApi = new GTUserApi($this); 75 | 76 | $domainUrl = trim($domainUrl); 77 | if ($ssl == NULL && $domainUrl != NULL && strpos(strtolower($domainUrl), "https:") === 0) { 78 | $ssl = true; 79 | } 80 | 81 | $this->useSSL = ($ssl == NULL ? false : $ssl); 82 | 83 | if ($domainUrl == NULL || strlen($domainUrl) == 0) { 84 | $this->domainUrlList = GTConfig::getDefaultDomainUrl($this->useSSL); 85 | } else { 86 | if (GTConfig::isNeedOSAsigned()) { 87 | $this->isAssigned = true; 88 | } 89 | $this->domainUrlList = array($domainUrl); 90 | } 91 | //鉴权 92 | try { 93 | $this->auth(); 94 | } catch (Exception $e) { 95 | echo $e->getMessage(); 96 | } 97 | } 98 | 99 | public function getAuthToken() 100 | { 101 | return $this->authToken; 102 | } 103 | 104 | public function setAuthToken($authToken) 105 | { 106 | $this->authToken = $authToken; 107 | } 108 | 109 | public function pushApi() 110 | { 111 | return $this->pushApi; 112 | } 113 | 114 | public function statisticsApi() 115 | { 116 | return $this->statisticsApi; 117 | } 118 | 119 | public function userApi() 120 | { 121 | return $this->userApi; 122 | } 123 | 124 | 125 | public function getHost() 126 | { 127 | return $this->domainUrlList[0]; 128 | } 129 | 130 | public function setDomainUrlList($domainUrlList) 131 | { 132 | $this->domainUrlList = $domainUrlList; 133 | } 134 | 135 | public function getAppId() 136 | { 137 | return $this->appId; 138 | } 139 | 140 | public function auth() 141 | { 142 | $auth = new GTAuthRequest(); 143 | $auth->setAppkey($this->appkey); 144 | $timeStamp = $this->getMicroTime(); 145 | $sign = hash("sha256", $this->appkey . $timeStamp . $this->masterSecret); 146 | $auth->setSign($sign); 147 | $auth->setTimestamp($timeStamp); 148 | $rep = $this->userApi()->auth($auth); 149 | if ($rep["code"] == 0) { 150 | $this->authToken = $rep["data"]["token"]; 151 | return true; 152 | } 153 | return false; 154 | } 155 | 156 | function getMicroTime() 157 | { 158 | list($usec, $sec) = explode(" ", microtime()); 159 | $time = ($sec . substr($usec, 2, 3)); 160 | return $time; 161 | } 162 | } -------------------------------------------------------------------------------- /GTPushApi.php: -------------------------------------------------------------------------------- 1 | gtClient = $gtClient; 14 | } 15 | 16 | //向单个用户推送消息,可根据cid指定用户 17 | function pushToSingleByCid($params){ 18 | return $this->post("/push/single/cid", $params->getApiParam()); 19 | } 20 | 21 | function pushToSingleByAlias($params){ 22 | return $this->post("/push/single/alias", $params->getApiParam()); 23 | } 24 | 25 | function pushBatchByCid($params){ 26 | return $this->post("/push/single/batch/cid", $params->getApiParam()); 27 | } 28 | 29 | function pushBatchByAlias($params){ 30 | return $this->post("/push/single/batch/alias", $params->getApiParam()); 31 | } 32 | 33 | function createListMsg($params){ 34 | return $this->post("/push/list/message", $params->getApiParam()); 35 | } 36 | 37 | function pushListByCid($params){ 38 | return $this->post("/push/list/cid", $params->getApiParam()); 39 | } 40 | 41 | function pushListByAlias($params){ 42 | return $this->post("/push/list/alias", $params->getApiParam()); 43 | } 44 | 45 | function pushAll($params){ 46 | return $this->post("/push/all", $params->getApiParam()); 47 | } 48 | 49 | function pushByTag($params){ 50 | return $this->post("/push/tag", $params->getApiParam()); 51 | } 52 | 53 | function pushByFastCustomTag($params){ 54 | return $this->post("/push/fast_custom_tag", $params->getApiParam()); 55 | } 56 | 57 | //停止任务 58 | function stopPush($params) 59 | { 60 | return $this->delete("/task/" . $params, null); 61 | } 62 | 63 | //查询定时任务状态 64 | function queryScheduleTask($params) 65 | { 66 | return $this->get("/task/schedule/" . $params, null); 67 | } 68 | 69 | //删除定时任务 70 | function deleteScheduleTask($params) 71 | { 72 | return $this->delete("/task/schedule/" . $params, null); 73 | } 74 | } -------------------------------------------------------------------------------- /GTStatisticsApi.php: -------------------------------------------------------------------------------- 1 | gtClient = $gtClient; 13 | } 14 | 15 | //查询推送数据,可查询消息有效可下发总数,消息回执总数和用户点击数等结果。支持单个taskId查询和多个taskId查询。 16 | //任务id,推送时返回,多个taskId以英文逗号隔开,一次最多传200个 17 | function queryPushResultByTaskIds($params){ 18 | return $this->get("/report/push/task/".implode(",", $params), null); 19 | } 20 | 21 | //根据任务组名查询推送结果,返回结果包括百日内联网用户数(活跃用户数)、实际下发数、到达数、展示数、点击数。 22 | function queryPushResultByGroupName($params){ 23 | return $this->get("/report/push/task_group/".$params, null); 24 | } 25 | 26 | //获取单日用户数据 27 | function queryUserDataByDate($params){ 28 | return $this->get("/report/user/date/".$params, null); 29 | } 30 | 31 | //获取单日推送数据 32 | function queryPushResultByDate($params){ 33 | return $this->get("/report/push/date/".$params, null); 34 | } 35 | 36 | //获取24小时在线用户数 37 | function queryOnlineUserData(){ 38 | return $this->get("/report/online_user", null); 39 | } 40 | } -------------------------------------------------------------------------------- /GTUserApi.php: -------------------------------------------------------------------------------- 1 | gtClient = $gtClient; 14 | } 15 | 16 | //鉴权 17 | function auth($params) 18 | { 19 | return $this->post("/auth", $params->getApiParam()); 20 | } 21 | 22 | //关闭鉴权,如果不传入token,则关闭该gtClient的token 23 | function closeAuth($params) 24 | { 25 | if($params != null){ 26 | return $this->delete("/auth/" . $params, null); 27 | }else{ 28 | return $this->delete("/auth/" . $this->gtClient->getAuthToken(), null); 29 | } 30 | } 31 | 32 | //用户绑定别名 33 | function bindAlias($params) 34 | { 35 | return $this->post("/user/alias", $params->getApiParam()); 36 | } 37 | 38 | //cid查别名 39 | function queryAliasByCid($params) 40 | { 41 | return $this->get("/user/alias/cid/" . $params, null); 42 | } 43 | 44 | //别名查cid 45 | function queryCidByAlias($params) 46 | { 47 | return $this->get("/user/cid/alias/" . $params, null); 48 | } 49 | 50 | //解绑别名cid 51 | function unbindAlias($params) 52 | { 53 | return $this->delete("/user/alias", $params->getApiParam()); 54 | } 55 | 56 | //解绑别名下所有cid 57 | function unbindAllAlias($params) 58 | { 59 | return $this->delete("/user/alias/" . $params, null); 60 | } 61 | 62 | 63 | //一个用户绑定一批标签,此操作为覆盖操作,会删除历史绑定的标签 64 | function setTagForCid($params) 65 | { 66 | return $this->post("/user/custom_tag/cid/" . $params->getCid(), $params->getApiParam()); 67 | } 68 | 69 | //根据cid查询用户标签列表 70 | function queryUserTag($params) 71 | { 72 | return $this->get("/user/custom_tag/cid/" . $params, null); 73 | } 74 | 75 | //一批用户绑定一个标签 76 | function batchModifyTagForBatchCid($params) 77 | { 78 | return $this->put("/user/custom_tag/batch/" . $params->getCustomTag(), $params->getApiParam()); 79 | } 80 | 81 | //解绑标签 82 | function unbindTag($params) 83 | { 84 | return $this->delete("/user/custom_tag/batch/" . $params->getCustomTag(), $params->getApiParam()); 85 | } 86 | 87 | //将单个或多个用户加入黑名单,对于黑名单用户在推送过程中会被过滤掉 88 | //cid:用户标识,多个以英文逗号隔开,一次最多传200个 89 | function addBlackUser($params) 90 | { 91 | return $this->post("/user/black/cid/" . implode(",", $params), null); 92 | } 93 | 94 | //查询用户状态 95 | //cid:用户标识,多个以英文逗号隔开,一次最多传200个 96 | function queryUserStatus($params) 97 | { 98 | return $this->get("/user/status/" . implode(",", $params), null); 99 | } 100 | 101 | //将单个cid或多个cid用户移出黑名单,对于黑名单用户在推送过程中会被过滤掉的,不会给黑名单用户推送消息 102 | //cid:用户标识,多个以英文逗号隔开,一次最多传200个 103 | function removeBlackUser($params) 104 | { 105 | return $this->delete("/user/black/cid/" . implode(",", $params), null); 106 | } 107 | 108 | //设置角标 109 | function setBadge($params) 110 | { 111 | return $this->post("/user/badge/cid/" . implode(",", $params->getCids()), $params->getApiParam()); 112 | } 113 | 114 | //通过指定查询条件来查询满足条件的用户数量 115 | function queryUserCount($params) 116 | { 117 | return $this->post("/user/count", $params->getApiParam()); 118 | } 119 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 欢迎使用[个推**PUSH** SDK For PHP](https://docs.getui.com/getui/server/rest_v2/introduction/)。 2 | 3 | `个推PUSH SDK For PHP`的主要目标是提升开发者在**服务端**集成个推推送服务的开发效率。 4 | 开发者不需要进行复杂编程即可使用个推推送服务的各项常用功能,SDK可以自动帮您满足调用过程中所需的鉴权、组装参数、发送HTTP请求等非功能性要求。 5 | 6 | 下面向您介绍`个推PUSH SDK For PHP`的使用方法。 7 | 8 | 9 | ## 环境要求 10 | 1. 需要配合`PHP 5.5`或其以上版本。 11 | 12 | 2. 使用`个推PUSH SDK`前,您需要先前往[个推开发者中心](https://dev.getui.com) 完成开发者接入的一些准备工作,创建应用。详细见[操作步骤](https://docs.getui.com/getui/start/devcenter/#1) 13 | 14 | 3. 准备工作完成后,前往[个推开发者中心](https://dev.getui.com)获取应用配置,后续将作为使用SDK的输入。详细见[操作步骤](https://docs.getui.com/getui/start/devcenter/#11) 15 | 16 | 17 | ## 快速开始 18 | ### 普通调用 19 | 下列代码示例向您展示了使用`个推Push SDK For PHP`调用一个API的3个主要步骤: 20 | 21 | 1. 设置参数,创建API。 22 | 2. 发起API调用。 23 | 3. 处理响应。 24 | 25 | ##### 使用示例:**推送API**_根据cid进行单推 26 | 27 | ```php 28 | function pushToSingleByCid(){ 29 | //创建API,APPID等配置参考 环境要求 进行获取 30 | $api = new GTClient("https://restapi.getui.com","APPKEY", "APPID","MASTERSECRET"); 31 | //设置推送参数 32 | $push = new GTPushRequest(); 33 | $push->setRequestId("请求唯一标识号"); 34 | $message = new GTPushMessage(); 35 | $notify = new GTNotification(); 36 | $notify->setTitle("设置通知标题"); 37 | $notify->setBody("设置通知内容"); 38 | //点击通知后续动作,目前支持以下后续动作: 39 | //1、intent:打开应用内特定页面url:打开网页地址。2、payload:自定义消息内容启动应用。3、payload_custom:自定义消息内容不启动应用。4、startapp:打开应用首页。5、none:纯通知,无后续动作 40 | $notify->setClickType("none"); 41 | $message->setNotification($notify); 42 | $push->setPushMessage($message); 43 | $push->setCid("CID"); 44 | //处理返回结果 45 | $result = $api->pushApi()->pushToSingleByCid($push); 46 | } 47 | ``` 48 | 49 | ##### 使用示例:**统计API**_获取单日推送数据 50 | ```php 51 | function queryPushResultByDate(){ 52 | //创建API,APPID等配置参考 环境要求 进行获取 53 | $api = new GTClient("https://restapi.getui.com","APPKEY", "APPID","MASTERSECRET"); 54 | //处理返回结果 55 | $result = $api->statisticsApi()->queryPushResultByDate("年-月-日"); 56 | } 57 | ``` 58 | 59 | 60 | ##### 使用示例:**用户API**_查询用户状态 61 | ```php 62 | function queryUserStatus(){ 63 | //创建API,APPID等配置参考 环境要求 进行获取 64 | $api = new GTClient("https://restapi.getui.com","APPKEY", "APPID","MASTERSECRET"); 65 | $array = array(CID1); 66 | //处理返回结果 67 | $result = $api->userApi()->queryUserStatus($array); 68 | } 69 | ``` 70 | > 其余功能[可参考该链接](https://github.com/GetuiLaboratory/getui-pushapi-php-client-v2/tree/master/test) 71 | 72 | 73 | ### 设置代理 74 | > 我们提供系统环境变量的方式进行代理配置,当需要使用代理进行http访问时,配置以下环境变量 75 | 76 | ```php 77 | "getui_http_proxy_ip" : 代理ip 78 | "getui_http_proxy_port" : 代理端口 79 | "getui_http_proxy_username" : 鉴权用户名 80 | "getui_http_proxy_passwd" : 鉴权密码 81 | ``` 82 | 83 | 84 | ## 已支持的API列表 85 | 以下是消息推送功能与推送API的对应关系 86 | 87 | | API类别 | 功能 | 调用的API名称 | 88 | |-----------|-----------------|-----------------------------------------------------------| 89 | | 鉴权API | [鉴权](https://docs.getui.com/getui/server/rest_v2/token/#0) | 初始化GTClient会自动鉴权 | 90 | | 鉴权API | [删除鉴权](https://docs.getui.com/getui/server/rest_v2/token/#1) | GTUserApi.closeAuth | 91 | | 推送API | [cid单推](https://docs.getui.com/getui/server/rest_v2/push/#1) | GTUserApi.pushToSingleByCid | 92 | | 推送API | [别名单推](https://docs.getui.com/getui/server/rest_v2/push/#2) | GTUserApi.pushToSingleByAlias | 93 | | 推送API | [cid批量单推](https://docs.getui.com/getui/server/rest_v2/push/#3) | GTUserApi.pushBatchByCid | 94 | | 推送API | [别名批量单推](https://docs.getui.com/getui/server/rest_v2/push/#4) | GTUserApi.pushBatchByAlias | 95 | | 推送API | [tolist创建消息](https://docs.getui.com/getui/server/rest_v2/push/#5) | GTUserApi.createListMsg | 96 | | 推送API | [cid批量推](https://docs.getui.com/getui/server/rest_v2/push/#6) | GTUserApi.pushListByCid | 97 | | 推送API | [别名批量推](https://docs.getui.com/getui/server/rest_v2/push/#7) | GTUserApi.pushListByAlias | 98 | | 推送API | [群推](https://docs.getui.com/getui/server/rest_v2/push/#8) | GTUserApi.pushAll | 99 | | 推送API | [条件筛选用户推送](https://docs.getui.com/getui/server/rest_v2/push/#9) | GTUserApi.pushByTag | 100 | | 推送API | [标签快速推送](https://docs.getui.com/getui/server/rest_v2/push/#10) | GTUserApi.pushByFastCustomTag | 101 | | 推送API | [停止任务](https://docs.getui.com/getui/server/rest_v2/push/#11) | GTUserApi.stopPush | 102 | | 推送API | [查询定时任务](https://docs.getui.com/getui/server/rest_v2/push/#12) | GTUserApi.queryScheduleTask | 103 | | 推送API | [删除定时任务](https://docs.getui.com/getui/server/rest_v2/push/#13) | GTUserApi.deleteScheduleTask | 104 | | 统计API | [获取推送结果](https://docs.getui.com/getui/server/rest_v2/report/#1) | GTStatisticsApi.queryPushResultByTaskIds | 105 | | 统计API | [任务组名查报表](https://docs.getui.com/getui/server/rest_v2/report/#2) | GTStatisticsApi.queryPushResultByGroupName | 106 | | 统计API | [单日推送数据](https://docs.getui.com/getui/server/rest_v2/report/#3) | GTStatisticsApi.queryPushResultByDate | 107 | | 统计API | [单日用户数据接口](https://docs.getui.com/getui/server/rest_v2/report/#4) | GTStatisticsApi.queryUserDataByDate | 108 | | 统计API | [24小时在线用户数](https://docs.getui.com/getui/server/rest_v2/report/#5) | GTStatisticsApi.queryOnlineUserData | 109 | | 用户API | [绑定别名](https://docs.getui.com/getui/server/rest_v2/user/#1) | GTUserApi.bindAlias | 110 | | 用户API | [根据cid查询别名](https://docs.getui.com/getui/server/rest_v2/user/#2) | GTUserApi.queryAliasByCid | 111 | | 用户API | [根据别名查询cid](https://docs.getui.com/getui/server/rest_v2/user/#3) | GTUserApi.queryCidByAlias | 112 | | 用户API | [批量解绑别名](https://docs.getui.com/getui/server/rest_v2/user/#4) | GTUserApi.unbindAlias | 113 | | 用户API | [解绑所有别名](https://docs.getui.com/getui/server/rest_v2/user/#5) | GTUserApi.unbindAllAlias | 114 | | 用户API | [一个用户绑定一批标签](https://docs.getui.com/getui/server/rest_v2/user/#6) | GTUserApi.setTagForCid | 115 | | 用户API | [一批用户绑定一个标签](https://docs.getui.com/getui/server/rest_v2/user/#7) | GTUserApi.batchModifyTagForBatchCid | 116 | | 用户API | [一批用户解绑一个标签](https://docs.getui.com/getui/server/rest_v2/user/#8) | GTUserApi.unbindTag | 117 | | 用户API | [查询标签](https://docs.getui.com/getui/server/rest_v2/user/#9) | GTUserApi.queryUserTag | 118 | | 用户API | [添加黑名单用户](https://docs.getui.com/getui/server/rest_v2/user/#10) | GTUserApi.addBlackUser | 119 | | 用户API | [移除黑名单用户](https://docs.getui.com/getui/server/rest_v2/user/#11) | GTUserApi.removeBlackUser | 120 | | 用户API | [查询用户状态](https://docs.getui.com/getui/server/rest_v2/user/#12) | GTUserApi.queryUserStatus | 121 | | 用户API | [设置角标(仅支持IOS)](https://docs.getui.com/getui/server/rest_v2/user/#13) | GTUserApi.setBadge | 122 | | 用户API | [查询用户总量](https://docs.getui.com/getui/server/rest_v2/user/#14) | GTUserApi.queryUserCount | 123 | 124 | > 注:更多API持续更新中,敬请期待。 125 | 126 | 127 | ## 其他链接 128 | [个推开发者平台](https://docs.getui.com/) 129 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "getuilaboratory/getui-pushapi-php-client-v2", 3 | "description": "getui php client V2", 4 | "keywords": ["getui", "getuilaboratory", "getui-pushapi-php-client","getui-pushapi-php-client-v2", "pushapi"], 5 | "homepage": "https://www.getui.com/cn/", 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "getui", 10 | "homepage": "https://www.getui.com/cn" 11 | } 12 | ], 13 | "autoload": { 14 | "classmap": [""] 15 | } 16 | } -------------------------------------------------------------------------------- /exception/GTException.php: -------------------------------------------------------------------------------- 1 | requestId = $a1; 21 | } 22 | 23 | public function getRequestId() 24 | { 25 | return $this->requestId; 26 | } 27 | } -------------------------------------------------------------------------------- /request/GTApiRequest.php: -------------------------------------------------------------------------------- 1 | apiParam; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /request/auth/GTAuthRequest.php: -------------------------------------------------------------------------------- 1 | sign; 17 | } 18 | 19 | public function setSign($sign) 20 | { 21 | $this->sign = $sign; 22 | $this->apiParam["sign"] = $sign; 23 | } 24 | 25 | public function getTimestamp() 26 | { 27 | return $this->timestamp; 28 | } 29 | 30 | public function setTimestamp($timestamp) 31 | { 32 | $this->timestamp = $timestamp; 33 | $this->apiParam["timestamp"] = $timestamp; 34 | } 35 | 36 | public function getAppkey() 37 | { 38 | return $this->appkey; 39 | } 40 | 41 | public function setAppkey($appkey) 42 | { 43 | $this->appkey = $appkey; 44 | $this->apiParam["appkey"] = $appkey; 45 | } 46 | } -------------------------------------------------------------------------------- /request/push/GTAudienceRequest.php: -------------------------------------------------------------------------------- 1 | cidList; 14 | } 15 | 16 | public function setCidList($cidList) 17 | { 18 | $this->cidList = $cidList; 19 | } 20 | 21 | public function getAliasList() 22 | { 23 | return $this->aliasList; 24 | } 25 | 26 | public function setAliasList($aliasList) 27 | { 28 | $this->aliasList = $aliasList; 29 | } 30 | 31 | public function getTaskid() 32 | { 33 | return $this->taskid; 34 | } 35 | 36 | public function setTaskid($taskid) 37 | { 38 | $this->taskid = $taskid; 39 | $this->apiParam["taskid"] = $taskid; 40 | } 41 | 42 | public function getIsAsync() 43 | { 44 | return $this->isAsync; 45 | } 46 | 47 | public function setIsAsync($isAsync) 48 | { 49 | $this->isAsync = $isAsync; 50 | $this->apiParam["is_async"] = $isAsync; 51 | } 52 | 53 | public function getApiParam() 54 | { 55 | if ($this->aliasList != null){ 56 | $audience["alias"] = $this->aliasList; 57 | $this->apiParam["audience"] = $audience; 58 | } 59 | if ($this->cidList != null){ 60 | $audience["cid"] = $this->cidList; 61 | $this->apiParam["audience"] = $audience; 62 | } 63 | return $this->apiParam; 64 | } 65 | } -------------------------------------------------------------------------------- /request/push/GTCondition.php: -------------------------------------------------------------------------------- 1 | key; 10 | } 11 | 12 | public function setKey($key) 13 | { 14 | $this->key = $key; 15 | $this->apiParam["key"] = $key; 16 | } 17 | 18 | public function getValues() 19 | { 20 | return $this->values; 21 | } 22 | 23 | public function setValues($values) 24 | { 25 | $this->values = $values; 26 | } 27 | 28 | public function getOptType() 29 | { 30 | return $this->opt_type; 31 | } 32 | 33 | public function setOptType($opt_type) 34 | { 35 | $this->opt_type = $opt_type; 36 | $this->apiParam["opt_type"] = $opt_type; 37 | } 38 | 39 | public function getApiParam() 40 | { 41 | if ($this->values != null){ 42 | $this->apiParam["values"] = $this->values; 43 | } 44 | return $this->apiParam; 45 | } 46 | } -------------------------------------------------------------------------------- /request/push/GTNotification.php: -------------------------------------------------------------------------------- 1 | title; 81 | } 82 | 83 | public function setTitle($title) 84 | { 85 | $this->title = $title; 86 | $this->apiParam["title"] = $title; 87 | } 88 | 89 | public function getBody() 90 | { 91 | return $this->body; 92 | } 93 | 94 | public function setBody($body) 95 | { 96 | $this->body = $body; 97 | $this->apiParam["body"] = $body; 98 | } 99 | 100 | public function getBigText() 101 | { 102 | return $this->bigText; 103 | } 104 | 105 | public function setBigText($bigText) 106 | { 107 | $this->bigText = $bigText; 108 | $this->apiParam["big_text"] = $bigText; 109 | } 110 | 111 | public function getBigImage() 112 | { 113 | return $this->bigImage; 114 | } 115 | 116 | public function setBigImage($bigImage) 117 | { 118 | $this->bigImage = $bigImage; 119 | $this->apiParam["big_image"] = $bigImage; 120 | } 121 | 122 | public function getLogo() 123 | { 124 | return $this->logo; 125 | } 126 | 127 | public function setLogo($logo) 128 | { 129 | $this->logo = $logo; 130 | $this->apiParam["logo"] = $logo; 131 | } 132 | 133 | public function getLogoUrl() 134 | { 135 | return $this->logoUrl; 136 | } 137 | 138 | public function setLogoUrl($logoUrl) 139 | { 140 | $this->logoUrl = $logoUrl; 141 | $this->apiParam["logo_url"] = $logoUrl; 142 | } 143 | 144 | public function getChannelId() 145 | { 146 | return $this->channelId; 147 | } 148 | 149 | public function setChannelId($channelId) 150 | { 151 | $this->channelId = $channelId; 152 | $this->apiParam["channel_id"] = $channelId; 153 | } 154 | 155 | public function getChannelName() 156 | { 157 | return $this->channelName; 158 | } 159 | 160 | public function setChannelName($channelName) 161 | { 162 | $this->channelName = $channelName; 163 | $this->apiParam["channel_name"] = $channelName; 164 | } 165 | 166 | public function getChannelLevel() 167 | { 168 | return $this->channelLevel; 169 | } 170 | 171 | public function setChannelLevel($channelLevel) 172 | { 173 | $this->channelLevel = $channelLevel; 174 | $this->apiParam["channel_level"] = $channelLevel; 175 | } 176 | 177 | public function getClickType() 178 | { 179 | return $this->clickType; 180 | } 181 | 182 | public function setClickType($clickType) 183 | { 184 | $this->clickType = $clickType; 185 | $this->apiParam["click_type"] = $clickType; 186 | } 187 | 188 | public function getIntent() 189 | { 190 | return $this->intent; 191 | } 192 | 193 | public function setIntent($intent) 194 | { 195 | $this->intent = $intent; 196 | $this->apiParam["intent"] = $intent; 197 | } 198 | 199 | public function getUrl() 200 | { 201 | return $this->url; 202 | } 203 | 204 | public function setUrl($url) 205 | { 206 | $this->url = $url; 207 | $this->apiParam["url"] = $url; 208 | } 209 | 210 | public function getPayload() 211 | { 212 | return $this->payload; 213 | } 214 | 215 | public function setPayload($payload) 216 | { 217 | $this->payload = $payload; 218 | $this->apiParam["payload"] = $payload; 219 | } 220 | 221 | public function getNotifyId() 222 | { 223 | return $this->notifyId; 224 | } 225 | 226 | public function setNotifyId($notifyId) 227 | { 228 | $this->notifyId = $notifyId; 229 | $this->apiParam["notify_id"] = $notifyId; 230 | } 231 | 232 | public function getRingName() 233 | { 234 | return $this->ringName; 235 | } 236 | 237 | public function setRingName($ringName) 238 | { 239 | $this->ringName = $ringName; 240 | $this->apiParam["ring_name"] = $ringName; 241 | 242 | } 243 | 244 | public function getBadgeAddNum() 245 | { 246 | return $this->badgeAddNum; 247 | } 248 | 249 | public function setBadgeAddNum($badgeAddNum) 250 | { 251 | $this->badgeAddNum = $badgeAddNum; 252 | $this->apiParam["badge_add_num"] = $badgeAddNum; 253 | } 254 | 255 | 256 | } -------------------------------------------------------------------------------- /request/push/GTPushBatchRequest.php: -------------------------------------------------------------------------------- 1 | isAsync; 13 | } 14 | 15 | public function setIsAsync($isAsync) 16 | { 17 | $this->isAsync = $isAsync; 18 | $this->apiParam["is_async"] = $isAsync; 19 | } 20 | 21 | public function getMsgList() 22 | { 23 | return $this->msgList; 24 | } 25 | 26 | public function addMsgList($msg) 27 | { 28 | array_push($this->msgList, $msg); 29 | } 30 | 31 | public function setMsgList($msg) 32 | { 33 | $this->msgList = $msg; 34 | } 35 | 36 | public function getApiParam() 37 | { 38 | if (!empty($this->msgList)){ 39 | $this->apiParam["msg_list"] = array(); 40 | foreach ($this->msgList as $value) { 41 | array_push($this->apiParam["msg_list"], $value->getApiParam()); 42 | } 43 | } 44 | return $this->apiParam; 45 | } 46 | } -------------------------------------------------------------------------------- /request/push/GTPushChannel.php: -------------------------------------------------------------------------------- 1 | ios; 20 | } 21 | 22 | public function setIos($ios) 23 | { 24 | $this->ios = $ios; 25 | } 26 | 27 | public function getAndroid() 28 | { 29 | return $this->android; 30 | } 31 | 32 | public function setAndroid($android) 33 | { 34 | $this->android = $android; 35 | } 36 | 37 | public function getApiParam() 38 | { 39 | if ($this->ios != null){ 40 | $this->apiParam["ios"] = $this->ios->getApiParam(); 41 | } 42 | if ($this->android != null){ 43 | $this->apiParam["android"] = $this->android->getApiParam(); 44 | } 45 | return $this->apiParam; 46 | } 47 | } -------------------------------------------------------------------------------- /request/push/GTPushMessage.php: -------------------------------------------------------------------------------- 1 | duration; 30 | } 31 | 32 | public function setDuration($duration) 33 | { 34 | $this->duration = $duration; 35 | $this->apiParam["duration"] = $duration; 36 | } 37 | 38 | public function getNotification() 39 | { 40 | return $this->notification; 41 | } 42 | 43 | public function setNotification($notification) 44 | { 45 | $this->notification = $notification; 46 | } 47 | 48 | public function getTransmission() 49 | { 50 | return $this->transmission; 51 | } 52 | 53 | public function setTransmission($transmission) 54 | { 55 | $this->transmission = $transmission; 56 | $this->apiParam["transmission"] = $transmission; 57 | } 58 | 59 | public function getRevoke() 60 | { 61 | return $this->revoke; 62 | } 63 | 64 | public function setRevoke($revoke) 65 | { 66 | $this->revoke = $revoke; 67 | } 68 | 69 | public function getApiParam() 70 | { 71 | if ($this->notification != null){ 72 | $this->apiParam["notification"] = $this->notification->getApiParam(); 73 | } 74 | if ($this->revoke != null){ 75 | $this->apiParam["revoke"] = $this->revoke->getApiParam(); 76 | } 77 | return $this->apiParam; 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /request/push/GTPushRequest.php: -------------------------------------------------------------------------------- 1 | fastCustomTag; 38 | } 39 | 40 | public function setFastCustomTag($fastCustomTag) 41 | { 42 | $this->fastCustomTag = $fastCustomTag; 43 | } 44 | 45 | public function getTagList() 46 | { 47 | return $this->tagList; 48 | } 49 | 50 | public function setTagList($tagList) 51 | { 52 | $this->tagList = $tagList; 53 | } 54 | 55 | public function getAliasList() 56 | { 57 | return $this->aliasList; 58 | } 59 | 60 | public function setAliasList($aliasList) 61 | { 62 | $this->aliasList = $aliasList; 63 | } 64 | 65 | public function getCid() 66 | { 67 | return $this->cid; 68 | } 69 | 70 | public function setCid($cid) 71 | { 72 | $this->cid = $cid; 73 | } 74 | 75 | public function getAlias() 76 | { 77 | return $this->alias; 78 | } 79 | 80 | public function setAlias($alias) 81 | { 82 | $this->alias = $alias; 83 | 84 | } 85 | 86 | public function getCidList() 87 | { 88 | return $this->cidList; 89 | } 90 | 91 | public function setCidList($cidList) 92 | { 93 | $this->cidList = $cidList; 94 | } 95 | 96 | public function getRequestId() 97 | { 98 | return $this->requestId; 99 | } 100 | 101 | public function setRequestId($requestId) 102 | { 103 | $this->requestId = $requestId; 104 | $this->apiParam["request_id"] = $requestId; 105 | } 106 | 107 | public function getGroupName() 108 | { 109 | return $this->groupName; 110 | } 111 | 112 | public function setGroupName($groupName) 113 | { 114 | $this->groupName = $groupName; 115 | $this->apiParam["group_name"] = $groupName; 116 | } 117 | 118 | public function getSettings() 119 | { 120 | return $this->settings; 121 | } 122 | 123 | public function setSettings($settings) 124 | { 125 | $this->settings = $settings; 126 | } 127 | 128 | public function getPushMessage() 129 | { 130 | return $this->pushMessage; 131 | } 132 | 133 | public function setPushMessage($pushMessage) 134 | { 135 | $this->pushMessage = $pushMessage; 136 | } 137 | 138 | public function getPushChannel() 139 | { 140 | return $this->pushChannel; 141 | } 142 | 143 | public function setPushChannel($pushChannel) 144 | { 145 | $this->pushChannel = $pushChannel; 146 | } 147 | 148 | public function getApiParam() 149 | { 150 | if ($this->pushMessage != null){ 151 | $this->apiParam["push_message"] = $this->pushMessage->getApiParam(); 152 | } 153 | if ($this->pushChannel){ 154 | $this->apiParam["push_channel"] = $this->pushChannel->getApiParam(); 155 | } 156 | if ($this->settings){ 157 | $this->apiParam["settings"] = $this->settings->getApiParam(); 158 | } 159 | 160 | $this->apiParam["audience"] = "all"; 161 | if ($this->cid != null) { 162 | $audience["cid"] = array($this->cid); 163 | $this->apiParam["audience"] = $audience; 164 | } 165 | if ($this->alias != null) { 166 | $audience["alias"] = array($this->alias); 167 | $this->apiParam["audience"] = $audience; 168 | } 169 | if ($this->cidList != null) { 170 | $audience["cid"] = $this->cidList; 171 | $this->apiParam["audience"] = $audience; 172 | } 173 | if ($this->aliasList != null) { 174 | $audience["alias"] = $this->aliasList; 175 | $this->apiParam["audience"] = $audience; 176 | } 177 | if ($this->tagList != null) { 178 | $audience["tag"] = array(); 179 | foreach ($this->tagList as $v) { 180 | array_push($audience["tag"], $v->getApiParam()); 181 | } 182 | $this->apiParam["audience"] = $audience; 183 | } 184 | if ($this->fastCustomTag != null) { 185 | $audience["fast_custom_tag"] = $this->fastCustomTag; 186 | $this->apiParam["audience"] = $audience; 187 | } 188 | return $this->apiParam; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /request/push/GTRevoke.php: -------------------------------------------------------------------------------- 1 | force; 17 | } 18 | 19 | public function setForce($force) 20 | { 21 | $this->force = $force; 22 | $this->apiParam["force"] = $force; 23 | } 24 | 25 | public function getOldTaskId() 26 | { 27 | return $this->oldTaskId; 28 | } 29 | 30 | public function setOldTaskId($oldTaskId) 31 | { 32 | $this->oldTaskId = $oldTaskId; 33 | $this->apiParam["old_task_id"] = $oldTaskId; 34 | } 35 | } -------------------------------------------------------------------------------- /request/push/GTSettings.php: -------------------------------------------------------------------------------- 1 | ttl; 27 | } 28 | 29 | public function setTtl($ttl) 30 | { 31 | $this->ttl = $ttl; 32 | $this->apiParam["ttl"] = $ttl; 33 | } 34 | 35 | public function getStrategy() 36 | { 37 | return $this->strategy; 38 | } 39 | 40 | public function setStrategy($strategy) 41 | { 42 | $this->strategy = $strategy; 43 | } 44 | 45 | public function getSpeed() 46 | { 47 | return $this->speed; 48 | } 49 | 50 | public function setSpeed($speed) 51 | { 52 | $this->speed = $speed; 53 | $this->apiParam["speed"] = $speed; 54 | } 55 | 56 | public function getScheduleTime() 57 | { 58 | return $this->scheduleTime; 59 | } 60 | 61 | public function setScheduleTime($scheduleTime) 62 | { 63 | $this->scheduleTime = $scheduleTime; 64 | $this->apiParam["schedule_time"] = $scheduleTime; 65 | } 66 | 67 | public function getApiParam() 68 | { 69 | if ($this->strategy != null){ 70 | $this->apiParam["strategy"] = $this->strategy->getApiParam(); 71 | } 72 | return $this->apiParam; 73 | } 74 | } -------------------------------------------------------------------------------- /request/push/GTStrategy.php: -------------------------------------------------------------------------------- 1 | default; 27 | } 28 | 29 | public function setDefault($default) 30 | { 31 | $this->default = $default; 32 | $this->apiParam["default"] = $default; 33 | } 34 | 35 | public function getIos() 36 | { 37 | return $this->ios; 38 | } 39 | 40 | public function setIos($ios) 41 | { 42 | $this->ios = $ios; 43 | $this->apiParam["ios"] = $ios; 44 | } 45 | 46 | public function getHw() 47 | { 48 | return $this->hw; 49 | } 50 | 51 | public function setHw($hw) 52 | { 53 | $this->hw = $hw; 54 | $this->apiParam["hw"] = $hw; 55 | } 56 | 57 | public function getXm() 58 | { 59 | return $this->xm; 60 | } 61 | 62 | public function setXm($xm) 63 | { 64 | $this->xm = $xm; 65 | $this->apiParam["xm"] = $xm; 66 | } 67 | 68 | public function getMz() 69 | { 70 | return $this->mz; 71 | } 72 | 73 | public function setMz($mz) 74 | { 75 | $this->mz = $mz; 76 | $this->apiParam["mz"] = $mz; 77 | } 78 | 79 | public function getOp() 80 | { 81 | return $this->op; 82 | } 83 | 84 | public function setOp($op) 85 | { 86 | $this->op = $op; 87 | $this->apiParam["op"] = $op; 88 | } 89 | 90 | public function getVv() 91 | { 92 | return $this->vv; 93 | } 94 | 95 | public function setVv($vv) 96 | { 97 | $this->vv = $vv; 98 | $this->apiParam["vv"] = $vv; 99 | } 100 | 101 | public function getSt() 102 | { 103 | return $this->st; 104 | } 105 | 106 | public function setSt($st) 107 | { 108 | $this->st = $st; 109 | $this->apiParam["st"] = $st; 110 | } 111 | 112 | public function getHx() 113 | { 114 | return $this->hx; 115 | } 116 | 117 | public function setHx($hx) 118 | { 119 | $this->hx = $hx; 120 | $this->apiParam["hx"] = $hx; 121 | } 122 | 123 | public function getHwq() 124 | { 125 | return $this->hwq; 126 | } 127 | 128 | public function setHwq($hwq) 129 | { 130 | $this->hwq = $hwq; 131 | $this->apiParam["hwq"] = $hwq; 132 | } 133 | } -------------------------------------------------------------------------------- /request/push/android/GTAndroid.php: -------------------------------------------------------------------------------- 1 | ups; 12 | } 13 | 14 | public function setUps($ups) 15 | { 16 | $this->ups = $ups; 17 | } 18 | 19 | public function getApiParam() 20 | { 21 | if ($this->ups != null){ 22 | $this->apiParam["ups"] = $this->ups->getApiParam(); 23 | } 24 | return $this->apiParam; 25 | } 26 | } -------------------------------------------------------------------------------- /request/push/android/GTThirdNotification.php: -------------------------------------------------------------------------------- 1 | title; 52 | } 53 | 54 | public function setTitle($title) 55 | { 56 | $this->title = $title; 57 | $this->apiParam["title"] = $title; 58 | } 59 | 60 | public function getBody() 61 | { 62 | return $this->body; 63 | } 64 | 65 | public function setBody($body) 66 | { 67 | $this->body = $body; 68 | $this->apiParam["body"] = $body; 69 | } 70 | 71 | public function getClickType() 72 | { 73 | return $this->clickType; 74 | } 75 | 76 | public function setClickType($clickType) 77 | { 78 | $this->clickType = $clickType; 79 | $this->apiParam["click_type"] = $clickType; 80 | } 81 | 82 | public function getIntent() 83 | { 84 | return $this->intent; 85 | } 86 | 87 | public function setIntent($intent) 88 | { 89 | $this->intent = $intent; 90 | $this->apiParam["intent"] = $intent; 91 | } 92 | 93 | public function getUrl() 94 | { 95 | return $this->url; 96 | } 97 | 98 | public function setUrl($url) 99 | { 100 | $this->url = $url; 101 | $this->apiParam["url"] = $url; 102 | } 103 | 104 | public function getPayload() 105 | { 106 | return $this->payload; 107 | } 108 | 109 | public function setPayload($payload) 110 | { 111 | $this->payload = $payload; 112 | $this->apiParam["payload"] = $payload; 113 | } 114 | 115 | public function getNotifyId() 116 | { 117 | return $this->notifyId; 118 | } 119 | 120 | public function setNotifyId($notifyId) 121 | { 122 | $this->notifyId = $notifyId; 123 | $this->apiParam["notify_id"] = $notifyId; 124 | } 125 | } -------------------------------------------------------------------------------- /request/push/android/GTUps.php: -------------------------------------------------------------------------------- 1 | notification; 37 | } 38 | 39 | public function setNotification($notification) 40 | { 41 | $this->notification = $notification; 42 | } 43 | 44 | public function getTransmission() 45 | { 46 | return $this->transmission; 47 | } 48 | 49 | public function setTransmission($transmission) 50 | { 51 | $this->transmission = $transmission; 52 | $this->apiParam["transmission"] = $transmission; 53 | } 54 | 55 | public function getOptions() 56 | { 57 | return $this->options; 58 | } 59 | 60 | public function setOptions($options) 61 | { 62 | $this->options = $options; 63 | } 64 | 65 | public function addOption($constraint, $key, $value){ 66 | if ($constraint == null){ 67 | $constraint = "ALL"; 68 | } 69 | $this->options[$constraint][$key] = $value; 70 | } 71 | // 72 | // public function addOptions($option) 73 | // { 74 | // if ($this->options == null) { 75 | // $this->options = array($option); 76 | // } else { 77 | // array_push($this->options, $option); 78 | // } 79 | // } 80 | 81 | public function getApiParam() 82 | { 83 | if ($this->notification != null) { 84 | $this->apiParam["notification"] = $this->notification->getApiParam(); 85 | } 86 | if ($this->options != null) { 87 | $this->apiParam["options"] = $this->options; 88 | } 89 | return $this->apiParam; 90 | } 91 | } -------------------------------------------------------------------------------- /request/push/ios/GTAlert.php: -------------------------------------------------------------------------------- 1 | title; 52 | } 53 | 54 | public function setTitle($title) 55 | { 56 | $this->title = $title; 57 | $this->apiParam["title"] = $title; 58 | } 59 | 60 | 61 | public function getBody() 62 | { 63 | return $this->body; 64 | } 65 | 66 | public function setBody($body) 67 | { 68 | $this->body = $body; 69 | $this->apiParam["body"] = $body; 70 | } 71 | 72 | public function getActionLocKey() 73 | { 74 | return $this->actionLocKey; 75 | } 76 | 77 | public function setActionLocKey($actionLocKey) 78 | { 79 | $this->actionLocKey = $actionLocKey; 80 | $this->apiParam["action-loc-key"] = $actionLocKey; 81 | } 82 | 83 | public function getLocKey() 84 | { 85 | return $this->locKey; 86 | } 87 | 88 | public function setLocKey($locKey) 89 | { 90 | $this->locKey = $locKey; 91 | $this->apiParam["loc-key"] = $locKey; 92 | } 93 | 94 | public function getLocArgs() 95 | { 96 | return $this->locArgs; 97 | } 98 | 99 | public function setLocArgs($locArgs) 100 | { 101 | $this->locArgs = $locArgs; 102 | } 103 | 104 | public function getLaunchImage() 105 | { 106 | return $this->launchImage; 107 | } 108 | 109 | public function setLaunchImage($launchImage) 110 | { 111 | $this->launchImage = $launchImage; 112 | $this->apiParam["launch-image"] = $launchImage; 113 | } 114 | 115 | public function getTitleLocKey() 116 | { 117 | return $this->titleLocKey; 118 | } 119 | 120 | public function setTitleLocKey($titleLocKey) 121 | { 122 | $this->titleLocKey = $titleLocKey; 123 | $this->apiParam["title-loc-key"] = $titleLocKey; 124 | } 125 | 126 | public function getTitleLocArgs() 127 | { 128 | return $this->titleLocArgs; 129 | } 130 | 131 | public function setTitleLocArgs($titleLocArgs) 132 | { 133 | $this->titleLocArgs = $titleLocArgs; 134 | } 135 | 136 | public function getSubtitle() 137 | { 138 | return $this->subtitle; 139 | } 140 | 141 | public function setSubtitle($subtitle) 142 | { 143 | $this->subtitle = $subtitle; 144 | $this->apiParam["subtitle"] = $subtitle; 145 | } 146 | 147 | public function getSubtitleLocKey() 148 | { 149 | return $this->subtitleLocKey; 150 | } 151 | 152 | public function setSubtitleLocKey($subtitleLocKey) 153 | { 154 | $this->subtitleLocKey = $subtitleLocKey; 155 | $this->apiParam["subtitle-loc-key"] = $subtitleLocKey; 156 | } 157 | 158 | public function getSubtitleLocArgs() 159 | { 160 | return $this->subtitleLocArgs; 161 | } 162 | 163 | public function setSubtitleLocArgs($subtitleLocArgs) 164 | { 165 | $this->subtitleLocArgs = $subtitleLocArgs; 166 | } 167 | 168 | public function getApiParam() 169 | { 170 | if ($this->subtitleLocArgs != null){ 171 | $this->apiParam["subtitle-loc-args"] = $this->subtitleLocArgs; 172 | } 173 | if ($this->titleLocArgs != null){ 174 | $this->apiParam["title-loc-args"] = $this->titleLocArgs; 175 | } 176 | if ($this->locArgs != null){ 177 | $this->apiParam["loc-args"] = $this->locArgs; 178 | } 179 | return $this->apiParam; 180 | } 181 | 182 | } -------------------------------------------------------------------------------- /request/push/ios/GTAps.php: -------------------------------------------------------------------------------- 1 | alert; 30 | } 31 | 32 | public function setAlert($alert) 33 | { 34 | $this->alert = $alert; 35 | } 36 | 37 | public function getContentAvailable() 38 | { 39 | return $this->contentAvailable; 40 | } 41 | 42 | public function setContentAvailable($contentAvailable) 43 | { 44 | $this->contentAvailable = $contentAvailable; 45 | $this->apiParam["content-available"] = $contentAvailable; 46 | } 47 | 48 | public function getSound() 49 | { 50 | return $this->sound; 51 | } 52 | 53 | public function setSound($sound) 54 | { 55 | $this->sound = $sound; 56 | $this->apiParam["sound"] = $sound; 57 | } 58 | 59 | public function getCategory() 60 | { 61 | return $this->category; 62 | } 63 | 64 | public function setCategory($category) 65 | { 66 | $this->category = $category; 67 | $this->apiParam["category"] = $category; 68 | } 69 | 70 | public function getThreadId() 71 | { 72 | return $this->threadId; 73 | } 74 | 75 | public function setThreadId($threadId) 76 | { 77 | $this->threadId = $threadId; 78 | $this->apiParam["thread-id"] = $threadId; 79 | } 80 | 81 | public function getApiParam() 82 | { 83 | if ($this->alert != null){ 84 | $this->apiParam["alert"] = $this->alert->getApiParam(); 85 | } 86 | return $this->apiParam; 87 | } 88 | } -------------------------------------------------------------------------------- /request/push/ios/GTIos.php: -------------------------------------------------------------------------------- 1 | type; 36 | } 37 | 38 | public function setType($type) 39 | { 40 | $this->type = $type; 41 | $this->apiParam["type"] = $type; 42 | } 43 | 44 | public function getAps() 45 | { 46 | return $this->aps; 47 | } 48 | 49 | public function setAps($aps) 50 | { 51 | $this->aps = $aps; 52 | } 53 | 54 | public function getAutoBadge() 55 | { 56 | return $this->autoBadge; 57 | } 58 | 59 | public function setAutoBadge($autoBadge) 60 | { 61 | $this->autoBadge = $autoBadge; 62 | $this->apiParam["auto_badge"] = $autoBadge; 63 | } 64 | 65 | public function getPayload() 66 | { 67 | return $this->payload; 68 | } 69 | 70 | public function setPayload($payload) 71 | { 72 | $this->payload = $payload; 73 | $this->apiParam["payload"] = $payload; 74 | } 75 | 76 | public function getMultimedia() 77 | { 78 | return $this->multimedia; 79 | } 80 | 81 | public function setMultimedia($multimedia) 82 | { 83 | $this->multimedia = $multimedia; 84 | } 85 | 86 | public function addMultimedia($multimedia) 87 | { 88 | if (empty($this->multimedia)) { 89 | $this->multimedia = array($multimedia); 90 | } else { 91 | array_push($this->multimedia, $multimedia); 92 | } 93 | } 94 | 95 | public function getApnsCollapseId() 96 | { 97 | return $this->apnsCollapseId; 98 | } 99 | 100 | public function setApnsCollapseId($apnsCollapseId) 101 | { 102 | $this->apnsCollapseId = $apnsCollapseId; 103 | $this->apiParam["apns-collapse-id"] = $apnsCollapseId; 104 | } 105 | 106 | public function getApiParam() 107 | { 108 | if ($this->multimedia != null){ 109 | $this->apiParam["multimedia"] = array(); 110 | foreach ($this->multimedia as $value) { 111 | array_push($this->apiParam["multimedia"], $value->getApiParam()); 112 | } 113 | } 114 | if ($this->aps != null){ 115 | $this->apiParam["aps"] = $this->aps->getApiParam(); 116 | } 117 | return $this->apiParam; 118 | } 119 | } -------------------------------------------------------------------------------- /request/push/ios/GTMultimedia.php: -------------------------------------------------------------------------------- 1 | url; 22 | } 23 | 24 | public function setUrl($url) 25 | { 26 | $this->url = $url; 27 | $this->apiParam["url"] = $url; 28 | } 29 | 30 | public function getType() 31 | { 32 | return $this->type; 33 | } 34 | 35 | public function setType($type) 36 | { 37 | $this->type = $type; 38 | $this->apiParam["type"] = $type; 39 | } 40 | 41 | public function getOnlyWifi() 42 | { 43 | return $this->onlyWifi; 44 | } 45 | 46 | public function setOnlyWifi($onlyWifi) 47 | { 48 | $this->onlyWifi = $onlyWifi; 49 | $this->apiParam["only_wifi"] = $onlyWifi; 50 | } 51 | } -------------------------------------------------------------------------------- /request/user/GTAliasRequest.php: -------------------------------------------------------------------------------- 1 | dataList; 15 | } 16 | 17 | //添加单个CidAlias 18 | public function addDataList($cidAlias) 19 | { 20 | array_push($this->dataList, $cidAlias); 21 | } 22 | 23 | //set CidAlias数组 24 | public function setDataList($cidAliasList) 25 | { 26 | $this->dataList = $cidAliasList; 27 | } 28 | 29 | public function getApiParam() 30 | { 31 | $this->apiParam["data_list"] = array(); 32 | foreach ($this->dataList as $value) { 33 | array_push($this->apiParam["data_list"], $value->getApiParam()); 34 | } 35 | return $this->apiParam; 36 | } 37 | } -------------------------------------------------------------------------------- /request/user/GTBadgeSetRequest.php: -------------------------------------------------------------------------------- 1 | badge; 18 | } 19 | 20 | public function setBadge($badge) 21 | { 22 | $this->badge = $badge; 23 | $this->apiParam["badge"] = $badge; 24 | } 25 | 26 | public function getCids() 27 | { 28 | return $this->cids; 29 | } 30 | 31 | public function setCids($cids) 32 | { 33 | $this->cids = $cids; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /request/user/GTCidAlias.php: -------------------------------------------------------------------------------- 1 | cid; 17 | } 18 | 19 | public function setCid($cid) 20 | { 21 | $this->cid = $cid; 22 | $this->apiParam["cid"] = $cid; 23 | } 24 | 25 | public function getAlias() 26 | { 27 | return $this->alias; 28 | } 29 | 30 | public function setAlias($alias) 31 | { 32 | $this->alias = $alias; 33 | $this->apiParam["alias"] = $alias; 34 | } 35 | } -------------------------------------------------------------------------------- /request/user/GTTagBatchSetRequest.php: -------------------------------------------------------------------------------- 1 | cid; 13 | } 14 | 15 | public function setCid($cid) 16 | { 17 | $this->cid = $cid; 18 | } 19 | 20 | public function getCustomTag() 21 | { 22 | return $this->customTag; 23 | } 24 | 25 | public function setCustomTag($customTag) 26 | { 27 | $this->customTag = $customTag; 28 | } 29 | 30 | public function getApiParam() 31 | { 32 | if ($this->cid != null){ 33 | $this->apiParam["cid"] = $this->cid; 34 | } 35 | return $this->apiParam; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /request/user/GTTagSetRequest.php: -------------------------------------------------------------------------------- 1 | cid; 13 | } 14 | 15 | public function setCid($cid) 16 | { 17 | $this->cid = $cid; 18 | } 19 | 20 | public function getCustomTag() 21 | { 22 | return $this->customTag; 23 | } 24 | 25 | public function setCustomTag($customTag) 26 | { 27 | $this->customTag = $customTag; 28 | $this->apiParam["custom_tag"] = $this->customTag; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /request/user/GTUserQueryRequest.php: -------------------------------------------------------------------------------- 1 | tag; 11 | } 12 | 13 | public function addTag($condition) 14 | { 15 | array_push($this->tag, $condition); 16 | } 17 | 18 | public function setTag($conditions) 19 | { 20 | $this->tag = $conditions; 21 | } 22 | 23 | public function getApiParam() 24 | { 25 | $this->apiParam["tag"] = array(); 26 | foreach ($this->tag as $value) { 27 | array_push($this->apiParam["tag"], $value->getApiParam()); 28 | } 29 | return $this->apiParam; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/PushApiTest.php: -------------------------------------------------------------------------------- 1 | setCid(CID3); 35 | global $api; 36 | echo json_encode($api->pushApi()->pushToSingleByCid($push)); 37 | } 38 | 39 | function pushToSingleByAlias(){ 40 | $push = getParam(); 41 | $push->setAlias("cccc"); 42 | 43 | global $api; 44 | echo json_encode($api->pushApi()->pushToSingleByAlias($push)); 45 | } 46 | 47 | function pushBatchByCid(){ 48 | $batch = new GTPushBatchRequest(); 49 | $push = getParam(); 50 | $push->setCid(CID3); 51 | // $push1 = getParam(); 52 | // $push1->setCid(CID1); 53 | $batch->setMsgList(array($push)); 54 | // $batch->addMsgList($push1); 55 | $batch->setIsAsync(false); 56 | 57 | global $api; 58 | echo json_encode($api->pushApi()->pushBatchByCid($batch)); 59 | } 60 | 61 | function pushBatchByAlias(){ 62 | $batch = new GTPushBatchRequest(); 63 | $push = getParam(); 64 | $push->setAlias("cccc"); 65 | 66 | $batch->addMsgList($push); 67 | $batch->setIsAsync(true); 68 | 69 | global $api; 70 | echo json_encode($api->pushApi()->pushBatchByAlias($batch)); 71 | } 72 | 73 | function createListMsg(){ 74 | $push = getParam(); 75 | $push->setGroupName("1202test"); 76 | global $api; 77 | echo json_encode($api->pushApi()->createListMsg($push)); 78 | } 79 | 80 | function pushListByCid(){ 81 | $user = new GTAudienceRequest(); 82 | $user->setIsAsync(true); 83 | $user->setTaskid("taskid"); 84 | $user->setCidList(array(CID3)); 85 | global $api; 86 | echo json_encode($api->pushApi()->pushListByCid($user)); 87 | } 88 | 89 | function pushListByAlias(){ 90 | $user = new GTAudienceRequest(); 91 | $user->setIsAsync(true); 92 | $user->setTaskid("taskid"); 93 | $user->setAliasList(array("cccc")); 94 | global $api; 95 | echo json_encode($api->pushApi()->pushListByAlias($user)); 96 | } 97 | 98 | function pushAll(){ 99 | $push = getParam(); 100 | $push->setGroupName("test"); 101 | global $api; 102 | echo json_encode($api->pushApi()->pushAll($push)); 103 | } 104 | 105 | function pushByTag(){ 106 | $push = getParam(); 107 | $tag1 = new GTCondition(); 108 | $tag1->setOptType("and"); 109 | $tag1->setKey("phone_type"); 110 | $tag1->setValues(array("IOS")); 111 | $push->setTagList(array($tag1)); 112 | global $api; 113 | echo json_encode($api->pushApi()->pushByTag($push)); 114 | } 115 | 116 | function pushByFastCustomTag(){ 117 | $push = getParam(); 118 | $push->setFastCustomTag("tag2"); 119 | global $api; 120 | echo json_encode($api->pushApi()->pushByFastCustomTag($push)); 121 | } 122 | 123 | function stoppushApi(){ 124 | global $api; 125 | echo json_encode($api->pushApi()->stopPush("taskid")); 126 | } 127 | 128 | function queryScheduleTask(){ 129 | global $api; 130 | echo json_encode($api->pushApi()->queryScheduleTask("taskid")); 131 | } 132 | 133 | function deleteScheduleTask(){ 134 | global $api,$tasId; 135 | echo json_encode($api->pushApi()->deleteScheduleTask("taskid")); 136 | } 137 | 138 | function getParam(){ 139 | $push = new GTPushRequest(); 140 | $push->setRequestId(micro_time()); 141 | //设置setting 142 | $set = new GTSettings(); 143 | $set->setTtl(3600000); 144 | // $set->setSpeed(1000); 145 | // $set->setScheduleTime(1591794372930); 146 | $strategy = new GTStrategy(); 147 | $strategy->setDefault(GTStrategy::STRATEGY_THIRD_FIRST); 148 | // $strategy->setIos(GTStrategy::STRATEGY_GT_ONLY); 149 | // $strategy->setOp(GTStrategy::STRATEGY_THIRD_FIRST); 150 | // $strategy->setHw(GTStrategy::STRATEGY_THIRD_ONLY); 151 | $set->setStrategy($strategy); 152 | $push->setSettings($set); 153 | //设置PushMessage, 154 | $message = new GTPushMessage(); 155 | //通知 156 | $notify = new GTNotification(); 157 | $notify->setTitle("notdifyddd"); 158 | $notify->setBody("notify bdoddy"); 159 | $notify->setBigText("bigTdext"); 160 | //与big_text二选一 161 | // $notify->setBigImage("BigImage"); 162 | 163 | $notify->setLogo("push.png"); 164 | $notify->setLogoUrl("LogoUrl"); 165 | $notify->setChannelId("Default"); 166 | $notify->setChannelName("Default"); 167 | $notify->setChannelLevel(2); 168 | 169 | $notify->setClickType("none"); 170 | $notify->setIntent("intent:#Intent;component=你的包名/你要打开的 activity 全路径;S.parm1=value1;S.parm2=value2;end"); 171 | $notify->setUrl("url"); 172 | $notify->setPayload("Payload"); 173 | $notify->setNotifyId(22334455); 174 | $notify->setRingName("ring_name"); 175 | $notify->setBadgeAddNum(1); 176 | // $message->setNotification($notify); 177 | //透传 ,与通知、撤回三选一 178 | $message->setTransmission("试试透传"); 179 | //撤回 180 | $revoke = new GTRevoke(); 181 | $revoke->setForce(true); 182 | $revoke->setOldTaskId("taskId"); 183 | // $message->setRevoke($revoke); 184 | $push->setPushMessage($message); 185 | $message->setDuration("1590547347000-1590633747000"); 186 | //厂商推送消息参数 187 | $pushChannel = new GTPushChannel(); 188 | //ios 189 | $ios = new GTIos(); 190 | $ios->setType("notify"); 191 | $ios->setAutoBadge("1"); 192 | $ios->setPayload("ios_payload"); 193 | $ios->setApnsCollapseId("apnsCollapseId"); 194 | //aps设置 195 | $aps = new GTAps(); 196 | $aps->setContentAvailable(0); 197 | $aps->setSound("com.gexin.ios.silenc"); 198 | $aps->setCategory("category"); 199 | $aps->setThreadId("threadId"); 200 | 201 | $alert = new GTAlert(); 202 | $alert->setTitle("alert title"); 203 | $alert->setBody("alert body"); 204 | $alert->setActionLocKey("ActionLocKey"); 205 | $alert->setLocKey("LocKey"); 206 | $alert->setLocArgs(array("LocArgs1","LocArgs2")); 207 | $alert->setLaunchImage("LaunchImage"); 208 | $alert->setTitleLocKey("TitleLocKey"); 209 | $alert->setTitleLocArgs(array("TitleLocArgs1","TitleLocArgs2")); 210 | $alert->setSubtitle("Subtitle"); 211 | $alert->setSubtitleLocKey("SubtitleLocKey"); 212 | $alert->setSubtitleLocArgs(array("subtitleLocArgs1","subtitleLocArgs2")); 213 | $aps->setAlert($alert); 214 | $ios->setAps($aps); 215 | 216 | $multimedia = new GTMultimedia(); 217 | $multimedia->setUrl("url"); 218 | $multimedia->setType(1); 219 | $multimedia->setOnlyWifi(false); 220 | $multimedia2 = new GTMultimedia(); 221 | $multimedia2->setUrl("url2"); 222 | $multimedia2->setType(2); 223 | $multimedia2->setOnlyWifi(true); 224 | $ios->setMultimedia(array($multimedia)); 225 | $ios->addMultimedia($multimedia2); 226 | $pushChannel->setIos($ios); 227 | //安卓 228 | $android = new GTAndroid(); 229 | $ups = new GTUps(); 230 | // $ups->setTransmission("ups Transmission"); 231 | $thirdNotification = new GTThirdNotification(); 232 | $thirdNotification->setTitle("title".micro_time()); 233 | $thirdNotification->setBody("body".micro_time()); 234 | $thirdNotification->setClickType(GTThirdNotification::CLICK_TYPE_URL); 235 | $thirdNotification->setIntent("intent:#Intent;component=你的包名/你要打开的 activity 全路径;S.parm1=value1;S.parm2=value2;end"); 236 | $thirdNotification->setUrl("http://docs.getui.com/getui/server/rest_v2/push/"); 237 | $thirdNotification->setPayload("payload"); 238 | $thirdNotification->setNotifyId(456666); 239 | $ups->addOption("HW","badgeAddNum",1); 240 | $ups->addOption("OP","channel","Default"); 241 | $ups->addOption("OP","aaa","bbb"); 242 | $ups->addOption(null,"a","b"); 243 | 244 | $ups->setNotification($thirdNotification); 245 | $android->setUps($ups); 246 | $pushChannel->setAndroid($android); 247 | $push->setPushChannel($pushChannel); 248 | 249 | return $push; 250 | } 251 | 252 | function micro_time() 253 | { 254 | list($usec, $sec) = explode(" ", microtime()); 255 | $time = ($sec . substr($usec, 2, 3)); 256 | return $time; 257 | } 258 | 259 | -------------------------------------------------------------------------------- /test/StatisticsApiTest.php: -------------------------------------------------------------------------------- 1 | statisticsApi()->queryPushResultByTaskIds(array("taskid"))); 24 | } 25 | 26 | function queryPushResultByGroupName(){ 27 | global $api; 28 | echo json_encode($api->statisticsApi()->queryPushResultByGroupName("test")); 29 | } 30 | 31 | function queryUserDataByDate(){ 32 | global $api; 33 | echo json_encode($api->statisticsApi()->queryUserDataByDate("2020-11-30")); 34 | } 35 | 36 | function queryOnlineUserData(){ 37 | global $api; 38 | echo json_encode($api->statisticsApi()->queryOnlineUserData()); 39 | } 40 | 41 | function queryPushResultByDate(){ 42 | global $api; 43 | echo json_encode($api->statisticsApi()->queryPushResultByDate("2020-11-30")); 44 | } 45 | -------------------------------------------------------------------------------- /test/UserApiTest.php: -------------------------------------------------------------------------------- 1 | userApi()->closeAuth()); 39 | } 40 | 41 | //用户 42 | function bindAlias1(){ 43 | $cidAliasListRequest = new GTAliasRequest(); 44 | // $als1 = new GTCidAlias(); 45 | // $als1->setCid(CID1); 46 | // $als1->setAlias("aaa"); 47 | $als2 = new GTCidAlias(); 48 | $als2->setCid(CID3); 49 | $als2->setAlias("cccc"); 50 | // $cidAliasListRequest->addDataList($als1); 51 | $cidAliasListRequest->addDataList($als2); 52 | global $api; 53 | echo json_encode($api->userApi()->bindAlias($cidAliasListRequest)); 54 | } 55 | 56 | function bindAlias2(){ 57 | $cidAliasListRequest = new GTAliasRequest(); 58 | $als1 = new GTCidAlias(); 59 | $als1->setCid(CID1); 60 | $als1->setAlias("tag1"); 61 | $als2 = new GTCidAlias(); 62 | $als2->setCid(CID3); 63 | $als2->setAlias("tag3"); 64 | $arr = array($als1,$als2); 65 | $cidAliasListRequest->setDataList($arr); 66 | global $api; 67 | echo json_encode($api->userApi()->bindAlias($cidAliasListRequest)); 68 | } 69 | 70 | function queryAliasByCid(){ 71 | global $api; 72 | echo json_encode($api->userApi()->queryAliasByCid(CID3)); 73 | } 74 | 75 | function queryCidByAlias(){ 76 | global $api; 77 | echo json_encode($api->userApi()->queryCidByAlias("tag1")); 78 | } 79 | 80 | function unBindAlias(){ 81 | $cidAliasListRequest = new GTAliasRequest(); 82 | $als1 = new GTCidAlias(); 83 | $als1->setCid(CID1); 84 | $als1->setAlias("aaa"); 85 | $cidAliasListRequest->addDataList($als1); 86 | global $api; 87 | echo json_encode($api->userApi()->unBindAlias($cidAliasListRequest)); 88 | } 89 | 90 | function unBindAllAlias(){ 91 | global $api; 92 | echo json_encode($api->userApi()->unBindAllAlias("tag1")); 93 | } 94 | 95 | function setTagForCid(){ 96 | $tags = new GTTagSetRequest(); 97 | $tags->setCid(CID1); 98 | $array = array("tag3","tag2","tag4"); 99 | $tags->setCustomTag($array); 100 | global $api; 101 | echo json_encode($api->userApi()->setTagForCid($tags)); 102 | } 103 | 104 | function batchModifyTagForBatchCid(){ 105 | $tags = new GTTagBatchSetRequest(); 106 | $tags->setCustomTag("tagb"); 107 | $array = array(CID1,CID2); 108 | $tags->setCid($array); 109 | global $api; 110 | echo json_encode($api->userApi()->batchModifyTagForBatchCid($tags)); 111 | } 112 | 113 | function unbindTag(){ 114 | $tags = new GTTagBatchSetRequest(); 115 | $tags->setCustomTag("tag3"); 116 | $array = array(CID1); 117 | $tags->setCid($array); 118 | global $api; 119 | $rep = $api->userApi()->unbindTag($tags); 120 | echo json_encode($rep); 121 | } 122 | 123 | function queryUserTag(){ 124 | global $api; 125 | $rep = $api->userApi()->queryUserTag(CID3); 126 | echo json_encode($rep); 127 | } 128 | 129 | function addBlackUser(){ 130 | $array = array(CID1); 131 | global $api; 132 | echo json_encode($api->userApi()->addBlackUser($array)); 133 | } 134 | 135 | function queryUserStatus(){ 136 | $array = array(CID1); 137 | global $api; 138 | echo json_encode($api->userApi()->queryUserStatus($array)); 139 | } 140 | 141 | function removeBlackUser(){ 142 | $array = array(CID1); 143 | global $api; 144 | echo json_encode($api->userApi()->removeBlackUser($array)); 145 | } 146 | 147 | function setBadge(){ 148 | $param = new GTBadgeSetRequest(); 149 | $param->setBadge(10); 150 | $array = array(CID1); 151 | $param->setCids($array); 152 | global $api; 153 | echo json_encode($api->userApi()->setBadge($param)); 154 | } 155 | 156 | function queryUserCount(){ 157 | $param = new GTUserQueryRequest(); 158 | $condition = new GTCondition(); 159 | $condition->setKey("custom_tag"); 160 | $condition->setValues(array("tagb")); 161 | $condition->setOptType("and"); 162 | $condition1 = new GTCondition(); 163 | $condition1->setKey("custom_tag"); 164 | $condition1->setValues(array("tag2")); 165 | $condition1->setOptType("and"); 166 | $param->setTag(array($condition1)); 167 | $param->addTag($condition); 168 | global $api; 169 | echo json_encode($api->userApi()->queryUserCount($param)); 170 | } 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /utils/GTConfig.php: -------------------------------------------------------------------------------- 1 | = 462850) { 64 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000); 65 | curl_setopt($curl, CURLOPT_NOSIGNAL, 1); 66 | } 67 | // 通过代理访问接口需要在此处配置代理 68 | curl_setopt ($curl, CURLOPT_PROXY, GTConfig::getHttpProxyIp()); 69 | curl_setopt($curl,CURLOPT_PROXYPORT,GTConfig::getHttpProxyPort()); 70 | curl_setopt($curl, CURLOPT_PROXYUSERNAME, GTConfig::getHttpProxyUserName()); 71 | curl_setopt($curl, CURLOPT_PROXYPASSWORD, GTConfig::getHttpProxyPasswd()); 72 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return don't print 73 | curl_setopt($curl, CURLOPT_TIMEOUT, 30); //设置超时时间 74 | curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); 75 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect 76 | curl_setopt($curl, CURLOPT_MAXREDIRS, 7); //HTTp定向级别 77 | //请求失败有3次重试机会 78 | $result = GTHttpManager::exeBySetTimes(GTConfig::getHttpTryCount(), $curl); 79 | return $result; 80 | } 81 | 82 | public static function httpRequest($url, $params,$headers, $gzip = false, $method) 83 | { 84 | $data = json_encode($params); 85 | $result = null; 86 | try { 87 | $resp = GTHttpManager::request($url, $data, $gzip,$method,$headers); 88 | $result = json_decode($resp, true); 89 | return $result; 90 | } catch (Exception $e) { 91 | throw new GTException($params["request_id"],"httpPost:[".$url."] [" .$data." ] [ ".$result."]:",$e); 92 | } 93 | } 94 | 95 | private static function exeBySetTimes($count, $curl) 96 | { 97 | $result = curl_exec($curl); 98 | $info = curl_getinfo($curl); 99 | $code = $info["http_code"]; 100 | if (curl_errno($curl) != 0 && $code != 200) { 101 | $count--; 102 | if ($count > 0) { 103 | $result = GTHttpManager::exeBySetTimes($count, $curl); 104 | } else { 105 | if ($code == 0 || $code == 404 || $code == 504){ 106 | throw new GTException("connect failed, code = ".strval($code)); 107 | } 108 | } 109 | } 110 | return $result; 111 | } 112 | } --------------------------------------------------------------------------------