[关闭]
@fuyb1986 2016-11-10T10:45:49.000000Z 字数 3123 阅读 1092

圈子和话题

金色童年


圈子列表

Method and URL Structure

Method Resource URL
GET /circles/

Request Paramaters

No Applicated

cURL Example

  1. curl http://localhost/circles/

Reponse

  1. {
  2. "count":5,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "name":"快乐成长",
  7. "topic_count":0,
  8. "has_member":false,
  9. "member_count":0
  10. },{
  11. "name":"金色童年",
  12. "topic_count":0,
  13. "has_member":false,
  14. "member_count":5,
  15. "like_count": 3,
  16. "has_like": true,
  17. },...]
  18. }

创建新话题

Method and URL Structure

Method Resource URL
POST /circles/topic/create/

Request Paramaters

Name Decription
circle 圈子 pk
title 标题
content 内容
photos 图片

Request Data

  1. {
  2. "circle": 5,
  3. "title": "君不见黄河之水天上来",
  4. "content": "度尽劫波兄弟在,相逢一笑泯恩仇。",
  5. "photos": "http://example.com/1.jpg,http://example.com/3.jpg,http://example.com/2.jpg",
  6. }

cURL Example

  1. curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' http://localhost/circles/topic/create/

Reponse

  1. {
  2. "circle":6,
  3. "title":"君不见黄河之水天上来",
  4. "content":"度尽劫波兄弟在,相逢一笑泯恩仇。",
  5. "photos":"http://example.com/1.jpg,http://example.com/3.jpg,http://example.com/2.jpg",
  6. "photo_list":[
  7. "http://example.com/1.jpg",
  8. "http://example.com/3.jpg",
  9. "http://example.com/2.jpg"
  10. ]
  11. }

获取话题列表、某个话题详情、删除话题

Method and URL Structure

Method Resource URL Description
GET /circles/${circle pk}/topics/ 列表
GET /circles/topic/${topi pk}/ 详情
DELETE /circles/topic/delete//${topi pk}/ 删除

cURL Example

  1. curl http://localhost/circles/121/topics/
  1. {
  2. "count":4,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":5,
  7. "owner":{
  8. "owner":3,
  9. "nickname":"xiaoming",
  10. "avatar_url":"http://www.example.com/xiaoming.jpg","slogan":"xiaoming's slogan"l
  11. },
  12. "title":"海客谈瀛洲,烟涛微茫信难求。",
  13. "photos":"http://example.com/1.jpg,http://example.com/3.jpg",
  14. "content":"越人语天姥,云霞明灭或可睹。 天姥连天向天横,势拔五岳掩赤城。",
  15. "photo_list":["http://example.com/1.jpg","http://example.com/3.jpg"],
  16. "created":"2016-10-10T17:50:56.057814",
  17. "comment_count":0,
  18. },... ]
  19. }

评论话题

Method and URL Structure

Method Resource URL
POST /circles/comment/create/

Request Paramaters

Name Decription
topic 话题 pk
content 内容

Request Data

  1. {
  2. "topic": 12345,
  3. "content": "天台一万八千丈,对此欲倒东南倾。",
  4. }

cURL Example

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

Reponse

  1. {
  2. "pk":1,
  3. "owner":{
  4. "owner":2,
  5. "nickname":"xiaoming",
  6. "avatar_url":"http://www.example.com/xiaoming.jpg",
  7. "slogan":"xiaoming's slogan"
  8. },
  9. "content":"天台一万八千丈,对此欲倒东南倾。",
  10. "topic":1,
  11. "created":"2016-10-10T18:23:23.338347"
  12. }

评论列表

Method and URL Structure

Method Resource URL Decription
GET /circles/topic/${topic pk}/comments/ 获取
DELETE /circles/comment/delete/${comment pk}/ 删除

cURL Example

  1. CURL http://localhost/circles/4341/comments/

Response

  1. {
  2. "count":5,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":6,
  7. "owner":{
  8. "owner":3,
  9. "nickname":"xiaoming",
  10. "avatar_url":"http://www.example.com/xiaoming.jpg",
  11. "slogan":"xiaoming's slogan"
  12. },
  13. "content":"天台一万八千丈,对此欲倒东南倾。",
  14. "topic":2,
  15. "created":"2016-10-10T18:34:02.847876",
  16. }, ...]
  17. }

点赞话题

Method and URL Structure

Method Resource URL
POST /circles/topic/like/
DELETE /circles/topic/{topic pk}/unlike/

Request Paramaters

Name Descrtiption
topic 话题 pk
user 用户 pk

Request Data

  1. {
  2. "topic": 3413,
  3. "user": 74929,
  4. }

cURL Example

  1. curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' http://localhost/circles/topic/like/
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注