11<?php
22include_once 'httpPostClient.php ' ;
33
4+ /**
5+ * 发送逻辑
6+ * @author xinxin
7+ *
8+ */
49class BaseClent
510{
611 private $ API_URL = "http://api.jpush.cn:8800/v2/push " ;
712
13+ /**
14+ * 构造函数
15+ */
816 public function __construct ()
917 {
1018 }
1119
1220
1321
1422 /**
15- *
23+ * 发送主体
1624 * @param int $sendno * 发送编号(最大支持32位正整数(即 4294967295 ))。
1725 * @param String $app_key * 待发送的应用程序(appKey),只能填一个。
1826 * @param int $receiver_type * 接收者类型。value: 2、指定的 tag。3、指定的 alias。4、广播:对 app_key 下的所有用户推送消息。
@@ -34,6 +42,21 @@ public function send($sendno, $app_key, $receiver_type, $receiver_value, $verifi
3442 return $ httpPostClient ->request_post ($ this ->API_URL , $ params );
3543 }
3644
45+ /**
46+ * 拼接url参数
47+ * @param int $sendno * 发送编号(最大支持32位正整数(即 4294967295 ))。
48+ * @param String $app_key * 待发送的应用程序(appKey),只能填一个。
49+ * @param int $receiver_type * 接收者类型。value: 2、指定的 tag。3、指定的 alias。4、广播:对 app_key 下的所有用户推送消息。
50+ * @param String $receiver_value 发送范围值 tag:支持多达 10 个,使用 "," 间隔。alias:支持多达 1000 个,使用 "," 间隔。广播:不需要填
51+ * @param String $verification_code * 验证串,用于校验发送的合法性
52+ * @param int $msg_type * 发送消息的类型:1、通知2、自定义消息(只有 Android 支持)
53+ * @param String $msg_content * 发送消息的内容
54+ * @param String $send_description 描述此次发送调用。
55+ * @param String $platform * 目标用户终端手机的平台类型,如: android, ios 多个请使用逗号分隔。
56+ * @param int $time_to_live 从消息推送时起,保存离线的时长。秒为单位。最多支持10天(864000秒)。 0 表示该消息不保存离线。
57+ * @param String $override_msg_id 待覆盖的上一条消息的 ID。
58+ * @return string
59+ */
3760 private function getParams ($ sendno , $ app_key , $ receiver_type , $ receiver_value , $ verification_code ,
3861 $ msg_type , $ msg_content , $ send_description , $ platform , $ time_to_live , $ override_msg_id )
3962 {
@@ -45,5 +68,52 @@ private function getParams($sendno, $app_key, $receiver_type, $receiver_value, $
4568 //echo $params."\n";
4669 return $ params ;
4770 }
71+
72+
73+ /**
74+ * 消息发送体
75+ * @param String $mes_title
76+ * @param String $mes_content
77+ * @param int $mes_type
78+ * @param String $extras
79+ * @return string
80+ */
81+ public function getContent ($ mes_title , $ mes_content , $ mes_type , $ extras )
82+ {
83+ //echo "mes_title=".$mes_title."mes_content=".$mes_content."mes_type=".$mes_type."extras=".$extras;
84+ $ content_str = '' ;
85+ if ($ mes_type == 1 )
86+ {
87+ $ content = array ('n_title ' =>$ mes_title , 'n_content ' =>$ mes_content , 'n_extras ' =>$ extras );
88+ $ content_str = json_encode ($ content );
89+ }
90+ else if ($ mes_type == 2 )
91+ {
92+ $ content = array ('title ' =>$ mes_title , 'message ' =>$ mes_content , 'extras ' =>$ extras );
93+ $ content_str = json_encode ($ content );
94+ }
95+ //echo $content_str;
96+ return $ content_str ;
97+ }
98+
99+
100+ /**
101+ * 获取验证字符串_md5加密
102+ * @param int $sendno
103+ * @param int $receiver_type
104+ * @param String $receiver_value
105+ * @return String
106+ */
107+ public function getVerification_code ($ sendno , $ receiver_type , $ receiver_value )
108+ {
109+ $ verification_str = $ sendno .$ receiver_type .$ receiver_value .$ this ->masterSecret ;
110+ $ verification_str = md5 ($ verification_str );
111+ return $ verification_str ;
112+ }
113+
114+ protected function getBase64_code ($ app_key , $ masterSecret )
115+ {
116+
117+ }
48118}
49119?>
0 commit comments