[关闭]
@fuyb1986 2017-03-08T10:09:41.000000Z 字数 2244 阅读 598

每日一星评论

金色童年


评论每日一星

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

  1. {
  2. "title": "随风潜入夜,润物细无声。",
  3. "content": "天台一万八千丈,对此欲倒东南倾。",
  4. }

cURL Example

  1. curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' \
  2. http://localhost/comment/create/?post=34

Reponse

  1. {
  2. "pk": 9,
  3. owner":{
  4. "owner":4,
  5. "username":"18516271364",
  6. "nickname":"xiaoming",
  7. "avatar_url":"http://www.example.com/xiaoming.jpg",
  8. "slogan":"xiaoming's slogan",
  9. "name":"",
  10. "sex":"S",
  11. "sex_display":"保密",
  12. "birthday":null
  13. },
  14. "content":"天台一万八千丈,对此欲倒东南倾。",
  15. "title": "随风潜入夜,润物细无声。",
  16. "published":"2017-02-21",
  17. "post_id":5,"
  18. "created":"2016-10-10T18:23:23.338347"
  19. }

评论列表

Method and URL Structure

Method Resource URL Decription
GET /comment/ 获取评论列表

Request Parameters

Name Decription Required
post 每日一星 post_id True

cURL Example

  1. curl http://localhost/comment/?post=13469

Response

  1. {
  2. "count":2,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":4,
  7. "owner":{
  8. "owner":4,
  9. "username":"18516271364",
  10. "nickname":"xiaoming",
  11. "avatar_url":"http://www.example.com/xiaoming.jpg",
  12. "slogan":"xiaoming's slogan",
  13. "name":"",
  14. "sex":"S",
  15. "sex_display":"保密",
  16. "birthday":null
  17. },
  18. "title":"随风潜入夜,润物细无声。",
  19. "content":"海客谈瀛洲,烟波微茫信难求。",
  20. "published":"2017-02-21",
  21. "post_id":13469,
  22. "like_count": 9,
  23. "has_like": ture,
  24. "created":"2017-02-21T19:53:55.719382"
  25. },{
  26. "pk":3,
  27. "owner":{
  28. "owner":4,
  29. "username":"18516271364",
  30. "nickname":"xiaoming",
  31. "avatar_url":"http://www.example.com/xiaoming.jpg",
  32. "slogan":"xiaoming's slogan",
  33. "name":"",
  34. "sex":"S",
  35. "sex_display":"保密",
  36. "birthday":null
  37. },
  38. "title":"随风潜入夜,润物细无声。",
  39. "content":"海客谈瀛洲,烟波微茫信难求。",
  40. "published":"2017-02-21",
  41. "post_id": 13469,
  42. "like_count": 9,
  43. "has_like": ture,
  44. "created":"2017-02-21T19:53:55.717174"
  45. }]
  46. }

删除评论

Method and URL Structure

Method Resource URL Decription
DELETE /comment/${pk}/ 删除评论

cURL Example

  1. curl -X DELETE http://localhost/comment/5/

点赞评论

Method and URL Structure

Method Rescource URL Description
POST /comment/${pk}/like/ 点赞评论

cURL Example

  1. curl -X POST http://localhost/comment/5/like/

Response

  1. {
  2. "pk":12,
  3. "title":"随风潜入夜,润物细无声。",
  4. "content":"海客谈瀛洲,烟波微茫信难求。",
  5. "published":"2017-03-08",
  6. "owner":{...},
  7. "post_id":6,
  8. "created":"2017-03-08T18:08:01.697594",
  9. "reply_set":[],
  10. "parent":null,
  11. "like_count":3,
  12. "has_like":true
  13. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注