好友
金色童年
好友列表
Method and URL Structure
| Method |
Resource URL |
| GET |
/friend/ |
cURL Example
curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\http://localhost/friend/
Response
{ "count":3, "next":null, "previous":null, "results":[{ "user":{ "owner":16, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"", "sex":"S", "sex_display":"保密" }, "state":true, "circle":"friend", "circle_display":"朋友" },.... ]}
添加一个好友
Method and URL Structure
| Method |
Resource URL |
| POST |
/friend/add/ |
Request Paramaters
| Name |
Description |
Required |
Defalut |
| circle |
关系 |
NO |
friend |
| user |
好友 id |
YES |
|
Request Data
{ "circel": "friend" "user": 1234}
cURL Example
curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\--data '{...}' http://localhost/friend/add/
Response
{ "pk":11, "circle":"family", "user":18, "friend_list":7}
更新好友关系
Method and URL Structure
| Method |
Resource URL |
| PATCH |
/friend/update/${pk}/ |
Request Paramaters
| Name |
Description |
Required |
Defalut |
| circle |
关系 |
NO |
friend |
Request Data
{ "circel": "family"}
cURL Example
curl -X PATCH -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\--data '{...}' http://localhost/friend/update/12/
Response
{ "pk":11, "circle":"family", "user":18, "friend_list":7}
获取、删除一个好友信息
Method and URL Structure
| Method |
Resource URL |
| GET |
/friend/${pk}/ |
| DELETE |
/friend/delete/${pk}/ |
cURL Example
curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\http://localhost/friend/12/
Response
{ "user":{ "owner":12, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"", "sex":"S", "sex_display":"保密" }, "state":true, "circle":"friend", "circle_display":"朋友"}