Skip to content

Commit d9b4606

Browse files
committed
eidt README.MD
1 parent 6d3eb6d commit d9b4606

File tree

3 files changed

+87
-172
lines changed

3 files changed

+87
-172
lines changed

.idea/workspace.xml

Lines changed: 52 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 32 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -20,141 +20,54 @@
2020
* 如果当前的 PHP 版本未支持 SSL,需要重新编译安装 PHP 以支持。请 Google 文档了解。
2121
* 重启 Apache。
2222

23-
## 使用样例
24-
25-
### 推送API
26-
```php
27-
28-
/**
29-
* 推送API
30-
* @param String $tags tag字符串。多个tag以','(逗号)分隔
31-
* @param String $alias alia字符串。多个alia以','(逗号)分隔
32-
* @param String $registrations registritionId字符串。多个以','(逗号)分隔
33-
* @param int $sendno 发送编号,最大支持32位正整数
34-
* @param String $title 通知标题。填 空字符串 则默认使用该应用的名称
35-
* @param String $content 通知内容
36-
* @param String $content_type Message字段里的内容类型
37-
* @param String $description 描述此次发送调用,不会发到用户
38-
* @param array $extras 通知附加参数,默认为[]
39-
* @param String $build_id 通知框样式,默认为0
40-
* @param String $override_msg_id 待覆盖的上一条消息的 ID,默认为0
41-
*
42-
* @return MessageResult $msgResult 错误信息对象
43-
*/
44-
//发送广播通知
45-
public function sendNotification($sendno, $title, $content, $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
46-
47-
//发送tag通知
48-
public function sendTagNotification($tags, $sendno, $title, $content, $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
49-
50-
//发送alias通知
51-
public function sendAliasNotification($alias, $sendno, $title, $content, $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
52-
53-
//发送RegistrationID通知
54-
public function sendRegistrationIDNotification($registrations, $sendno, $title, $content, $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
55-
56-
//发送广播自定义消息
57-
public function sendCustomMsg($sendno, $title, $content, $content_type = '', $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
23+
## 依赖
24+
* PHP-CURL
25+
* PHPUnit
5826

59-
//发送tag自定义消息
60-
public function sendTagCustomMsg($tags, $sendno, $title, $content, $content_type = '', $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
61-
62-
//发送alias自定义消息
63-
public function sendAliasCustomMsg($alias, $sendno, $title, $content, $content_type = '', $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
64-
65-
//发送RegistrationID自定义消息
66-
public function sendRegistrationIDCustomMsg($registrations, $sendno, $title, $content, $content_type = '', $description = '', $extras = array(), $build_id = '', $override_msg_id = '');
27+
### 安装 PHP-CURL
6728

6829
```
30+
sudo apt-get install php5-curl
31+
sudo service apache2 restart
32+
```
33+
其他操作系统安装请访问 [安装PHP-CURL][1]
6934

70-
### 使用样例
71-
72-
```php
73-
$client = new JPushClient($app_key,$master_secret);
74-
75-
//发送广播通知
76-
$msgResult1 = $client->sendNotification($sendno, $title, $content);
77-
78-
//发送tag通知
79-
$msgResult2 = $client->sendTagNotification($tags, $sendno, $title, $content);
80-
81-
//发送alias通知
82-
$msgResult3 = $client->sendAliasNotification($alias, $sendno, $title, $content);
83-
84-
//发送RegistrationID通知
85-
$msgResult4 = $client->sendRegistrationIDNotification($registrationId, $sendno, $title, $content);
86-
87-
//发送广播自定义消息
88-
$msgResult5 = $client->sendCustomMsg($sendno, $title, $content, $content-type);
89-
90-
//发送tag自定义消息
91-
$msgResult6 = $client->sendTagCustomMsg($tags, $sendno, $title, $content, $content-type);
92-
93-
//发送alias自定义消息
94-
$msgResult7 = $client->sendAliasCustomMsg($alias, $sendno, $title, $content, $content-type);
95-
96-
//发送RegistrationID自定义消息
97-
$msgResult8 = $client->sendRegistrationIDCustomMsg($registrationId, $sendno, $title, $content, $content-type);
98-
35+
### 安装 PHPUnit
36+
```
37+
pear channel-discover pear.phpunit.de
38+
pear install phpunit/PHPUnit
39+
```
40+
进行测试
9941
```
42+
cd test
43+
phpunit AllTest.php
44+
```
45+
46+
## 使用样例
10047

101-
### 统计获取API
48+
### 推送API使用样例
10249

10350
```php
104-
/**
105-
* 获取统计信息
106-
* @param String $msg_ids msg_id以,连接
107-
*
108-
* @return Json对象
109-
*/
110-
public function getReportReceiveds($msg_ids);
111-
51+
//发送广播通知
52+
$client = new JPushClient($app_key, $master_secret);
53+
$payload = new PushClient();
54+
$notification = new Notification();
55+
$notification->alert = "alert message";
56+
$result1 = $client->sendPush($payload);
11257
```
11358

114-
### 统计获取返回JSON格式
115-
116-
```javascript
117-
//SUCCESS
118-
[
119-
{
120-
"android_received": 62,
121-
"ios_apns_sent": 11,
122-
"msg_id": 1613113584
123-
},
124-
{
125-
"android_received": 56,
126-
"ios_apns_sent": 33,
127-
"msg_id": 1229760629
128-
},
129-
{
130-
"android_received": null,
131-
"ios_apns_sent": 14,
132-
"msg_id": 1174658841
133-
},
134-
{
135-
"android_received": 32,
136-
"ios_apns_sent": null,
137-
"msg_id": 1174658641
138-
}
139-
]
140-
141-
//ERROR
142-
{
143-
"error": {
144-
"code": 3001,
145-
"message": "Basic authentication failed"
146-
}
147-
}
148-
```
14959

150-
### 统计获取样例
60+
### 统计获取API使用样例
15161

15262
```php
15363
$client = new JPushClient($app_key,$master_secret);
154-
$msg_ids = "123,12345";
155-
$msgstr = $client->getReportReceiveds($msg_ids);
64+
$msg_ids = '636946851,1173817748,636946865';
65+
$msgstr = $client->getReport($msg_ids);
15666
```
15767

15868

15969
## 版本更新
16070
[Release页面](https://github.com/jpush/jpush-api-php-client/releases/) 有详细的版本发布记录与下载。
71+
72+
73+
[1]: http://www.php.net/manual/zh/curl.installation.php

examples/example.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282

8383
/* init end */
8484

85-
85+
$payload = new PushClient();
86+
$notification = new Notification();
87+
$notification->alert = "alert message";
8688

8789

8890
//发送广播通知

0 commit comments

Comments
 (0)