Skip to content

Commit a714343

Browse files
committed
update readme.md
1 parent 41ac57e commit a714343

File tree

1 file changed

+72
-17
lines changed

1 file changed

+72
-17
lines changed

README.md

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# JPush API client library for PHP - README
2+
3+
标签: JPush
4+
5+
---
6+
17
[![Build Status](https://travis-ci.org/jpush/jpush-api-php-client.svg?branch=master)](https://travis-ci.org/jpush/jpush-api-php-client)
28

39
# JPush API client library for PHP
@@ -12,26 +18,54 @@
1218
PHP >= 5.3
1319

1420
### 快速安装
15-
解压 **examples/vendor.tar.gz** 到项目目录,在需要使用JPush的源文件头部 引入 vendor/autoload.php 既可使用。
16-
```php
17-
require_once 'vendor/autoload.php';
21+
JPush PHP Library 使用 Composer管理项目依赖, 鉴于某些原因, 国内的用户使用Composer下载依赖库比较困难,所以我们将Composer依赖打包. 用户可以通过以下方式在您的项目中加入JPush PHP Library.
22+
23+
24+
1.下载依赖包 [vendor.tar.gz][3]
25+
2.解压 [vendor.tar.gz][4] 到您的项目目录下,在需要使用JPush的源文件头部 引入 `vendor/autoload.php` 既可使用。
1826
```
27+
# 引入代码
28+
php require_once 'vendor/autoload.php';
29+
```
30+
PS: 在下载的[JPush PHP Library][5]中的[example][6]文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法.
31+
32+
33+
34+
### 使用 Composer
1935

36+
如果你的项目使用composer管理依赖, 可以通过以下方式使用JPush PHP Library.
2037

21-
### Composer install
2238

23-
Use composer to fetch the library and dependencies defined in `composer.json`, and install them:
39+
1.`composer.json` 中添加 jpush依赖, 目前最新版本为 v3.2.0
2440

2541
```
26-
#download the composer.phar
27-
$ curl -sS https://getcomposer.org/installer | php
28-
#install by composer.json
29-
$ php composer.phar install
42+
{
43+
"require":{
44+
"jpush/jpush": "v3.2.0"
45+
}
46+
}
3047
```
48+
2. 执行 `php composer.phar install``php composer.phar update`
49+
3150

3251

3352

3453
## 快速使用
54+
55+
### Example
56+
57+
[example][6]文件夹有简单示例代码, 开发者可参考以快速使用该库
58+
59+
├── examples
60+
│   ├── composer.json 项目依赖
61+
│   ├── DeviceExample.php 对Tag, Alias, Registeration_id的操作示例
62+
│   ├── PushExample.php 推送示例
63+
│   ├── README.md 说明
64+
│   ├── ReportExample.php 获取统计信息示例
65+
│   └── ValidateExample.php 使用validate接口示例
66+
67+
68+
3569
### Easy Push
3670

3771
```php
@@ -80,20 +114,41 @@ foreach($result->received_list as $received) {
80114
}
81115
```
82116

117+
## FAQ
118+
119+
Q: 运行示例提示 `require_once(vendor/autoload.php): failed to open stream` 怎么解决?
120+
A: 下载下载依赖包 [vendor.tar.gz][3] 并解压到examples目录即可, 也可以使用composer管理依赖, 在composer.json中加入 `"jpush/jpush": "v3.2.0"` 并执行 `php composer.phar install` 即可.
121+
122+
Q: 运行示例提示
123+
```
124+
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "jpush.log" could not be opened: failed to open stream: Permission denied
125+
```
126+
该如何解决?
127+
A: 此问题是因为工程没有写入权限导致不能生成日志文件. 只需对赋予该项目对本目录的写入权限即可,如 `sudo chmod 777 example`
128+
129+
Q: 使用示例每次推送都会打印推送的JSON, 如何禁止其打印?
130+
A: 在调用示例推送的时候, 注释掉 `->printJSON()` 即可, 该函数可以打印当前构建的推送对象.
131+
132+
133+
83134
## 文档
84135

85-
* [JPush Push API v3][4]
86-
* [JPush Report API][5]
87-
* [JPush Api PHP client doc][6]
136+
* [JPush Push API v3][7]
137+
* [JPush Report API][8]
138+
* [JPush Api PHP client doc][9]
88139

89140
## 版本更新
90141

91-
[Release页面][7]有详细的版本发布记录与下载。
142+
[Release页面][10]有详细的版本发布记录与下载。
92143

93144

94145
[1]: http://docs.jpush.cn/display/dev/Push-API-v3
95146
[2]: http://docs.jpush.cn/display/dev/Report-API
96-
[4]: http://docs.jpush.cn/display/dev/Push-API-v3
97-
[5]: http://docs.jpush.cn/display/dev/Report-API
98-
[6]: doc/api.md
99-
[7]: https://github.com/jpush/jpush-api-php-client/releases/
147+
[3]: http://jpushsdk.qiniudn.com/vendor.tar.gz
148+
[4]: http://jpushsdk.qiniudn.com/vendor.tar.gz
149+
[5]: http://jpushsdk.qiniudn.com/jpush-api-php-client-v3.2.0.tar.gz
150+
[6]: /examples
151+
[7]: http://docs.jpush.cn/display/dev/Push-API-v3
152+
[8]: http://docs.jpush.cn/display/dev/Report-API
153+
[9]: doc/api.md
154+
[10]: https://github.com/jpush/jpush-api-php-client/releases/

0 commit comments

Comments
 (0)