CloudpushPushRequest.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <?php
  2. /**
  3. * TOP API: taobao.cloudpush.push request
  4. *
  5. * @author auto create
  6. * @since 1.0, 2015.11.16
  7. */
  8. class CloudpushPushRequest
  9. {
  10. /**
  11. * Android对应的activity,仅仅当androidOpenType=2有效
  12. **/
  13. private $androidActivity;
  14. /**
  15. * 自定义的kv结构,开发者扩展用 针对android
  16. **/
  17. private $androidExtParameters;
  18. /**
  19. * android通知声音
  20. **/
  21. private $androidMusic;
  22. /**
  23. * 点击通知后动作,1:打开应用 2: 打开应用Activity 3:打开 url
  24. **/
  25. private $androidOpenType;
  26. /**
  27. * Android收到推送后打开对应的url,仅仅当androidOpenType=3有效
  28. **/
  29. private $androidOpenUrl;
  30. /**
  31. * 防打扰时长,取值范围为1~23
  32. **/
  33. private $antiHarassDuration;
  34. /**
  35. * 防打扰开始时间点,取值范围为0~23
  36. **/
  37. private $antiHarassStartTime;
  38. /**
  39. * 批次编号,用于活动效果统计
  40. **/
  41. private $batchNumber;
  42. /**
  43. * 推送内容
  44. **/
  45. private $body;
  46. /**
  47. * 设备类型,取值范围为:0~3云推送支持多种设备,各种设备类型编号如下: iOS设备:deviceType=0; Andriod设备:deviceType=1;如果存在此字段,则向指定的设备类型推送消息。 默认为全部(3);
  48. **/
  49. private $deviceType;
  50. /**
  51. * iOS应用图标右上角角标
  52. **/
  53. private $iosBadge;
  54. /**
  55. * 自定义的kv结构,开发者扩展用 针对iOS设备
  56. **/
  57. private $iosExtParameters;
  58. /**
  59. * iOS通知声音
  60. **/
  61. private $iosMusic;
  62. /**
  63. * 当APP不在线时候,是否通过通知提醒. 针对不同设备,处理逻辑不同。 该参数只针对iOS设备生效, (remind=true & 发送消息的话(type=0)). 当你的目标设备不在线(既长连接通道不通, 我们会将这条消息的标题,通过苹果的apns通道再送达一次。发apns是发送生产环境的apns,需要在云推送配置的app的iOS生产证书和密码需要正确,否则也发送不了。 (remind=false & 并且是发送消息的话(type=0)),那么设备不在线,则不会再走苹果apns发送了。
  64. **/
  65. private $remind;
  66. /**
  67. * 离线消息是否保存,若保存, 在推送时候,用户即使不在线,下一次上线则会收到
  68. **/
  69. private $storeOffline;
  70. /**
  71. * 通知的摘要
  72. **/
  73. private $summery;
  74. /**
  75. * 推送目标: device:推送给设备; account:推送给指定帐号,tag:推送给自定义标签; all: 推送给全部
  76. **/
  77. private $target;
  78. /**
  79. * 根据Target来设定,如Target=device, 则对应的值为 设备id1,设备id2. 多个值使用逗号分隔.(帐号与设备有一次最多100个的限制)
  80. **/
  81. private $targetValue;
  82. /**
  83. * 离线消息保存时长,取值范围为1~72,若不填,则表示不保存离线消息
  84. **/
  85. private $timeout;
  86. /**
  87. * 推送的标题内容.
  88. **/
  89. private $title;
  90. /**
  91. * 0:表示消息(默认为0),1:表示通知
  92. **/
  93. private $type;
  94. private $apiParas = array();
  95. public function setAndroidActivity($androidActivity)
  96. {
  97. $this->androidActivity = $androidActivity;
  98. $this->apiParas["android_activity"] = $androidActivity;
  99. }
  100. public function getAndroidActivity()
  101. {
  102. return $this->androidActivity;
  103. }
  104. public function setAndroidExtParameters($androidExtParameters)
  105. {
  106. $this->androidExtParameters = $androidExtParameters;
  107. $this->apiParas["android_ext_parameters"] = $androidExtParameters;
  108. }
  109. public function getAndroidExtParameters()
  110. {
  111. return $this->androidExtParameters;
  112. }
  113. public function setAndroidMusic($androidMusic)
  114. {
  115. $this->androidMusic = $androidMusic;
  116. $this->apiParas["android_music"] = $androidMusic;
  117. }
  118. public function getAndroidMusic()
  119. {
  120. return $this->androidMusic;
  121. }
  122. public function setAndroidOpenType($androidOpenType)
  123. {
  124. $this->androidOpenType = $androidOpenType;
  125. $this->apiParas["android_open_type"] = $androidOpenType;
  126. }
  127. public function getAndroidOpenType()
  128. {
  129. return $this->androidOpenType;
  130. }
  131. public function setAndroidOpenUrl($androidOpenUrl)
  132. {
  133. $this->androidOpenUrl = $androidOpenUrl;
  134. $this->apiParas["android_open_url"] = $androidOpenUrl;
  135. }
  136. public function getAndroidOpenUrl()
  137. {
  138. return $this->androidOpenUrl;
  139. }
  140. public function setAntiHarassDuration($antiHarassDuration)
  141. {
  142. $this->antiHarassDuration = $antiHarassDuration;
  143. $this->apiParas["anti_harass_duration"] = $antiHarassDuration;
  144. }
  145. public function getAntiHarassDuration()
  146. {
  147. return $this->antiHarassDuration;
  148. }
  149. public function setAntiHarassStartTime($antiHarassStartTime)
  150. {
  151. $this->antiHarassStartTime = $antiHarassStartTime;
  152. $this->apiParas["anti_harass_start_time"] = $antiHarassStartTime;
  153. }
  154. public function getAntiHarassStartTime()
  155. {
  156. return $this->antiHarassStartTime;
  157. }
  158. public function setBatchNumber($batchNumber)
  159. {
  160. $this->batchNumber = $batchNumber;
  161. $this->apiParas["batch_number"] = $batchNumber;
  162. }
  163. public function getBatchNumber()
  164. {
  165. return $this->batchNumber;
  166. }
  167. public function setBody($body)
  168. {
  169. $this->body = $body;
  170. $this->apiParas["body"] = $body;
  171. }
  172. public function getBody()
  173. {
  174. return $this->body;
  175. }
  176. public function setDeviceType($deviceType)
  177. {
  178. $this->deviceType = $deviceType;
  179. $this->apiParas["device_type"] = $deviceType;
  180. }
  181. public function getDeviceType()
  182. {
  183. return $this->deviceType;
  184. }
  185. public function setIosBadge($iosBadge)
  186. {
  187. $this->iosBadge = $iosBadge;
  188. $this->apiParas["ios_badge"] = $iosBadge;
  189. }
  190. public function getIosBadge()
  191. {
  192. return $this->iosBadge;
  193. }
  194. public function setIosExtParameters($iosExtParameters)
  195. {
  196. $this->iosExtParameters = $iosExtParameters;
  197. $this->apiParas["ios_ext_parameters"] = $iosExtParameters;
  198. }
  199. public function getIosExtParameters()
  200. {
  201. return $this->iosExtParameters;
  202. }
  203. public function setIosMusic($iosMusic)
  204. {
  205. $this->iosMusic = $iosMusic;
  206. $this->apiParas["ios_music"] = $iosMusic;
  207. }
  208. public function getIosMusic()
  209. {
  210. return $this->iosMusic;
  211. }
  212. public function setRemind($remind)
  213. {
  214. $this->remind = $remind;
  215. $this->apiParas["remind"] = $remind;
  216. }
  217. public function getRemind()
  218. {
  219. return $this->remind;
  220. }
  221. public function setStoreOffline($storeOffline)
  222. {
  223. $this->storeOffline = $storeOffline;
  224. $this->apiParas["store_offline"] = $storeOffline;
  225. }
  226. public function getStoreOffline()
  227. {
  228. return $this->storeOffline;
  229. }
  230. public function setSummery($summery)
  231. {
  232. $this->summery = $summery;
  233. $this->apiParas["summery"] = $summery;
  234. }
  235. public function getSummery()
  236. {
  237. return $this->summery;
  238. }
  239. public function setTarget($target)
  240. {
  241. $this->target = $target;
  242. $this->apiParas["target"] = $target;
  243. }
  244. public function getTarget()
  245. {
  246. return $this->target;
  247. }
  248. public function setTargetValue($targetValue)
  249. {
  250. $this->targetValue = $targetValue;
  251. $this->apiParas["target_value"] = $targetValue;
  252. }
  253. public function getTargetValue()
  254. {
  255. return $this->targetValue;
  256. }
  257. public function setTimeout($timeout)
  258. {
  259. $this->timeout = $timeout;
  260. $this->apiParas["timeout"] = $timeout;
  261. }
  262. public function getTimeout()
  263. {
  264. return $this->timeout;
  265. }
  266. public function setTitle($title)
  267. {
  268. $this->title = $title;
  269. $this->apiParas["title"] = $title;
  270. }
  271. public function getTitle()
  272. {
  273. return $this->title;
  274. }
  275. public function setType($type)
  276. {
  277. $this->type = $type;
  278. $this->apiParas["type"] = $type;
  279. }
  280. public function getType()
  281. {
  282. return $this->type;
  283. }
  284. public function getApiMethodName()
  285. {
  286. return "taobao.cloudpush.push";
  287. }
  288. public function getApiParas()
  289. {
  290. return $this->apiParas;
  291. }
  292. public function check()
  293. {
  294. RequestCheckUtil::checkNotNull($this->body,"body");
  295. RequestCheckUtil::checkNotNull($this->deviceType,"deviceType");
  296. RequestCheckUtil::checkNotNull($this->remind,"remind");
  297. RequestCheckUtil::checkNotNull($this->storeOffline,"storeOffline");
  298. RequestCheckUtil::checkNotNull($this->target,"target");
  299. RequestCheckUtil::checkNotNull($this->targetValue,"targetValue");
  300. RequestCheckUtil::checkNotNull($this->title,"title");
  301. }
  302. public function putOtherTextParam($key, $value) {
  303. $this->apiParas[$key] = $value;
  304. $this->$key = $value;
  305. }
  306. }