Skip to content

Commit f1fea6c

Browse files
committed
recevice api
1 parent 7dec5e5 commit f1fea6c

File tree

2 files changed

+102
-11
lines changed

2 files changed

+102
-11
lines changed

lib/jpush_api_php_client.php

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
22
include_once 'jpush_api_php_client/baseClient.php';
33

4+
/**
5+
* Jpush客户端
6+
7+
*
8+
*/
49
class JpushClient
510
{
611

7-
/**
8-
*
9-
* @var unknown
10-
*/
12+
//密匙
1113
private $masterSecret;
14+
//离线市场
1215
private $time_to_live ;
1316

1417
/**
@@ -24,7 +27,7 @@ public function __construct($masterSecret, $timeToLive)
2427
}
2528

2629
/**
27-
*
30+
* 通过tag发送通知
2831
* @param Strng $tag
2932
* @param Strng $app_key
3033
* @param int $sendno
@@ -49,7 +52,7 @@ public function sendNotificationByTag($tag, $app_key, $sendno, $send_descriptio
4952
}
5053

5154
/**
52-
*
55+
* 通过tag发送自定义消息
5356
* @param Strng $tag
5457
* @param Strng $app_key
5558
* @param int $sendno
@@ -75,7 +78,7 @@ public function sendCustomMesByTag($tag, $app_key, $sendno, $send_description,
7578
}
7679

7780
/**
78-
*
81+
* 通过alias发送通知
7982
* @param Strng $alias
8083
* @param Strng $app_key
8184
* @param int $sendno
@@ -101,7 +104,7 @@ public function sendNotificationByAlias($alias, $app_key, $sendno, $send_descri
101104
}
102105

103106
/**
104-
*
107+
* 通过alias发送自定义消息
105108
* @param Strng $alias
106109
* @param Strng $app_key
107110
* @param int $sendno
@@ -127,7 +130,7 @@ public function sendCustomMesByAlias($alias, $app_key, $sendno, $send_descripti
127130
}
128131

129132
/**
130-
*
133+
* 发送广播通知
131134
* @param Strng $app_key
132135
* @param int $sendno
133136
* @param Strng $send_description
@@ -152,7 +155,7 @@ public function sendNotificationByAppkey($app_key, $sendno, $send_description,
152155
}
153156

154157
/**
155-
*
158+
* 发送广播自定义消息
156159
* @param Strng $app_key
157160
* @param int $sendno
158161
* @param Strng $send_description
@@ -176,6 +179,17 @@ public function sendCustomMesByAppkey($app_key, $sendno, $send_description,
176179

177180
}
178181

182+
/**
183+
*
184+
* @param String $app_key
185+
* @param String $msg_ids msg_id以,连接
186+
*/
187+
public function getReceivedApi($app_key, $msg_ids)
188+
{
189+
$
190+
191+
}
192+
179193
/**
180194
* 消息发送体
181195
* @param String $mes_title
@@ -203,6 +217,13 @@ private function getContent($mes_title, $mes_content, $mes_type, $extras)
203217
}
204218

205219

220+
/**
221+
* 获取验证字符串_md5加密
222+
* @param int $sendno
223+
* @param int $receiver_type
224+
* @param String $receiver_value
225+
* @return String
226+
*/
206227
private function getVerification_code($sendno, $receiver_type, $receiver_value)
207228
{
208229
$verification_str = $sendno.$receiver_type.$receiver_value.$this->masterSecret;

lib/jpush_api_php_client/baseClient.php

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
<?php
22
include_once 'httpPostClient.php';
33

4+
/**
5+
* 发送逻辑
6+
* @author xinxin
7+
*
8+
*/
49
class 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

Comments
 (0)