update readme for api usage

This commit is contained in:
2015-08-04 00:38:17 +08:00
parent 26dc39bfb3
commit 4837391d80
+67 -3
View File
@@ -10,7 +10,7 @@
#### API 调用
1 注册 127.0.0.1:3000/api/v1/sign_up
1 注册 POST: http://127.0.0.1:3000/api/v1/sign_up
- 参数:
* user[email]
@@ -29,7 +29,7 @@
}
```
2 登录 127.0.0.1:3000/api/v1/sign_in
2 登录 POST: http://127.0.0.1:3000/api/v1/sign_in
- 参数:
* user[email]
* user[password]
@@ -44,8 +44,72 @@
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjU0MGU4OTU4ODg3ZmI1MGI5YTA5YzI4MjQ2NTZlYTRlIn0.XQBWCNRYVdDvZwuBtafCyOkNpP8FEzwRqk8AhaHlaFc"
}
}
```
```
3 提交分享资源 POST: http://localhost:3000/api/v1/posts
- 参数
* 需要登录 传Authorization header
* url 网址
* type article 或者 web_page
* description 可选
- 返回
``` json
{
"id": 32,
"user_id": 3,
"sharable_id": 3,
"sharable_type": "WebPage",
"created_at": "2015-08-04T00:33:25.735+08:00",
"updated_at": "2015-08-04T00:33:25.735+08:00",
"description": "这是一个特别cool的github 项目",
"sharable": {
"id": 3,
"name": null,
"url": "http://mp.weixin.qq.com/s?__biz=MzA4NjAzMjEyOA==&mid=207485444&idx=1&sn=c0d5e1b2399fffbcdc5a5065eea52af8",
"created_at": "2015-08-04T00:33:25.627+08:00",
"updated_at": "2015-08-04T00:33:25.627+08:00",
"processed": false,
"view_account": 0
}
}
```
4 未注册用户首页数据 GET http://localhost:3000/api/v1/posts
- 参数
* 无
- 返回
``` json
[
{
"description": "这是我看到底第一篇他写的文章",
"sharable_type": "Article",
"sharable": {
"view_account": 0,
"url": "http://www.jianshu.com/p/bfbc77eecdb0",
"title": null
}
},
{
"description": "到底能不能成功啊,我去",
"sharable_type": "Article",
"sharable": {
"view_account": 0,
"url": "http://www.cnbeta.com/articles/416787.htm",
"title": null
}
},
{
"description": "这是一个特别cool的github 项目",
"sharable_type": "WebPage",
"sharable": {
"view_account": 0,
"url": "https://github.com/sparklemotion/mechanize",
"title": "sparklemotion/mechanize · GitHub"
}
```
#### 注意
* 注意,API返回结果中的token是利用JWT 技术加密的token,密钥是每个用户的email
* [jwt](http://jwt.io/)