每日一星评论
金色童年
评论每日一星
Method and URL Structure
| Method |
Resource URL |
| POST |
/comment/create/ |
Request Parameters
| Name |
Decription |
Required |
| post |
每日一星 post_id |
True |
Request Data
| Name |
Decription |
Required |
| title |
标题 |
True |
| content |
内容 |
True |
| parent |
上级评论 |
False |
Request Data
{ "title": "随风潜入夜,润物细无声。", "content": "天台一万八千丈,对此欲倒东南倾。",}
cURL Example
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' \http://localhost/comment/create/?post=34
Reponse
{ "pk": 9, owner":{ "owner":4, "username":"18516271364", "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"", "sex":"S", "sex_display":"保密", "birthday":null }, "content":"天台一万八千丈,对此欲倒东南倾。", "title": "随风潜入夜,润物细无声。", "published":"2017-02-21", "post_id":5," "created":"2016-10-10T18:23:23.338347"}
评论列表
Method and URL Structure
| Method |
Resource URL |
Decription |
| GET |
/comment/ |
获取评论列表 |
Request Parameters
| Name |
Decription |
Required |
| post |
每日一星 post_id |
True |
cURL Example
curl http://localhost/comment/?post=13469
Response
{ "count":2, "next":null, "previous":null, "results":[{ "pk":4, "owner":{ "owner":4, "username":"18516271364", "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"", "sex":"S", "sex_display":"保密", "birthday":null }, "title":"随风潜入夜,润物细无声。", "content":"海客谈瀛洲,烟波微茫信难求。", "published":"2017-02-21", "post_id":13469, "like_count": 9, "has_like": ture, "created":"2017-02-21T19:53:55.719382" },{ "pk":3, "owner":{ "owner":4, "username":"18516271364", "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"", "sex":"S", "sex_display":"保密", "birthday":null }, "title":"随风潜入夜,润物细无声。", "content":"海客谈瀛洲,烟波微茫信难求。", "published":"2017-02-21", "post_id": 13469, "like_count": 9, "has_like": ture, "created":"2017-02-21T19:53:55.717174" }]}
删除评论
Method and URL Structure
| Method |
Resource URL |
Decription |
| DELETE |
/comment/${pk}/ |
删除评论 |
cURL Example
curl -X DELETE http://localhost/comment/5/
点赞评论
Method and URL Structure
| Method |
Rescource URL |
Description |
| POST |
/comment/${pk}/like/ |
点赞评论 |
cURL Example
curl -X POST http://localhost/comment/5/like/
Response
{ "pk":12, "title":"随风潜入夜,润物细无声。", "content":"海客谈瀛洲,烟波微茫信难求。", "published":"2017-03-08", "owner":{...}, "post_id":6, "created":"2017-03-08T18:08:01.697594", "reply_set":[], "parent":null, "like_count":3, "has_like":true}