圈子和话题
金色童年
圈子列表
Method and URL Structure
| Method |
Resource URL |
| GET |
/circles/ |
Request Paramaters
No Applicated
cURL Example
curl http://localhost/circles/
Reponse
{ "count":5, "next":null, "previous":null, "results":[{ "name":"快乐成长", "topic_count":0, "has_member":false, "member_count":0 },{ "name":"金色童年", "topic_count":0, "has_member":false, "member_count":5, "like_count": 3, "has_like": true, },...]}
创建新话题
Method and URL Structure
| Method |
Resource URL |
| POST |
/circles/topic/create/ |
Request Paramaters
| Name |
Decription |
| circle |
圈子 pk |
| title |
标题 |
| content |
内容 |
| photos |
图片 |
Request Data
{ "circle": 5, "title": "君不见黄河之水天上来", "content": "度尽劫波兄弟在,相逢一笑泯恩仇。", "photos": "http://example.com/1.jpg,http://example.com/3.jpg,http://example.com/2.jpg",}
cURL Example
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' http://localhost/circles/topic/create/
Reponse
{ "circle":6, "title":"君不见黄河之水天上来", "content":"度尽劫波兄弟在,相逢一笑泯恩仇。", "photos":"http://example.com/1.jpg,http://example.com/3.jpg,http://example.com/2.jpg", "photo_list":[ "http://example.com/1.jpg", "http://example.com/3.jpg", "http://example.com/2.jpg" ]}
获取话题列表、某个话题详情、删除话题
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
curl http://localhost/circles/121/topics/
{ "count":4, "next":null, "previous":null, "results":[{ "pk":5, "owner":{ "owner":3, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg","slogan":"xiaoming's slogan"l }, "title":"海客谈瀛洲,烟涛微茫信难求。", "photos":"http://example.com/1.jpg,http://example.com/3.jpg", "content":"越人语天姥,云霞明灭或可睹。 天姥连天向天横,势拔五岳掩赤城。", "photo_list":["http://example.com/1.jpg","http://example.com/3.jpg"], "created":"2016-10-10T17:50:56.057814", "comment_count":0, },... ]}
评论话题
Method and URL Structure
| Method |
Resource URL |
| POST |
/circles/comment/create/ |
Request Paramaters
| Name |
Decription |
| topic |
话题 pk |
| content |
内容 |
Request Data
{ "topic": 12345, "content": "天台一万八千丈,对此欲倒东南倾。",}
cURL Example
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' http://localhost/circles/comment/create/
Reponse
{ "pk":1, "owner":{ "owner":2, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan" }, "content":"天台一万八千丈,对此欲倒东南倾。", "topic":1, "created":"2016-10-10T18:23:23.338347"}
评论列表
Method and URL Structure
| Method |
Resource URL |
Decription |
| GET |
/circles/topic/${topic pk}/comments/ |
获取 |
| DELETE |
/circles/comment/delete/${comment pk}/ |
删除 |
cURL Example
CURL http://localhost/circles/4341/comments/
Response
{ "count":5, "next":null, "previous":null, "results":[{ "pk":6, "owner":{ "owner":3, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan" }, "content":"天台一万八千丈,对此欲倒东南倾。", "topic":2, "created":"2016-10-10T18:34:02.847876", }, ...]}
点赞话题
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
{ "topic": 3413, "user": 74929,}
cURL Example
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ --data '{...}' http://localhost/circles/topic/like/