[关闭]
@fuyb1986 2016-10-25T11:59:27.000000Z 字数 1581 阅读 562

好友

金色童年


好友列表

Method and URL Structure

Method Resource URL
GET /friend/

cURL Example

  1. curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. http://localhost/friend/

Response

  1. {
  2. "count":3,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "user":{
  7. "owner":16,
  8. "nickname":"xiaoming",
  9. "avatar_url":"http://www.example.com/xiaoming.jpg",
  10. "slogan":"xiaoming's slogan",
  11. "name":"",
  12. "sex":"S",
  13. "sex_display":"保密"
  14. },
  15. "state":true,
  16. "circle":"friend",
  17. "circle_display":"朋友"
  18. },.... ]}

添加一个好友

Method and URL Structure

Method Resource URL
POST /friend/add/

Request Paramaters

Name Description Required Defalut
circle 关系 NO friend
user 好友 id YES

Request Data

  1. {
  2. "circel": "friend"
  3. "user": 1234
  4. }

cURL Example

  1. curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. --data '{...}' http://localhost/friend/add/

Response

  1. {
  2. "pk":11,
  3. "circle":"family",
  4. "user":18,
  5. "friend_list":7
  6. }

更新好友关系

Method and URL Structure

Method Resource URL
PATCH /friend/update/${pk}/

Request Paramaters

Name Description Required Defalut
circle 关系 NO friend

Request Data

  1. {
  2. "circel": "family"
  3. }

cURL Example

  1. curl -X PATCH -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. --data '{...}' http://localhost/friend/update/12/

Response

  1. {
  2. "pk":11,
  3. "circle":"family",
  4. "user":18,
  5. "friend_list":7
  6. }

获取、删除一个好友信息

Method and URL Structure

Method Resource URL
GET /friend/${pk}/
DELETE /friend/delete/${pk}/

cURL Example

  1. curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. http://localhost/friend/12/

Response

  1. {
  2. "user":{
  3. "owner":12,
  4. "nickname":"xiaoming",
  5. "avatar_url":"http://www.example.com/xiaoming.jpg",
  6. "slogan":"xiaoming's slogan",
  7. "name":"",
  8. "sex":"S",
  9. "sex_display":"保密"
  10. },
  11. "state":true,
  12. "circle":"friend",
  13. "circle_display":"朋友"
  14. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注