[关闭]
@shd 2018-04-13T05:47:51.000000Z 字数 2460 阅读 418

接口文档

接口


接口Output数据格式

成功:

  1. {
  2. "err": 0
  3. "data": {...}
  4. }

失败:

  1. {
  2. "err": 1 //error code
  3. "msg": "error description"
  4. }

接口

0 测试接口

get
/api/hello
post
/api/hello

1.1 编辑用户信息 (user)

put
/api/username

Input

  1. {
  2. "name": "名字"
  3. }

1.2 修改密码 (user)

post
/api/userpsd

  1. Input
  2. {
  3. "oldpsd": "xxxxxx",
  4. "newpsd": "qqqqqq"
  5. }

1.3 获取用户所在房间列表 (user)

get
/api/userroom/

  1. Output
  2. "roomlist": [
  3. {
  4. "group": [
  5. {
  6. "_id": "5a5dd61542d47c0528421ac0",
  7. "account": "1501140224",
  8. "name": "xhcxhc"
  9. },
  10. {
  11. "_id": "5a5dd67a42d47c0528421ac1",
  12. "account": "1031568754",
  13. "name": "user2"
  14. },
  15. {
  16. "_id": "5a618fdaf1ee3d37c8108c02",
  17. "account": "111222333",
  18. "name": "测试a"
  19. },
  20. {
  21. "_id": "5a66e2d08552523e703e6822",
  22. "account": "123456",
  23. "name": "ccccc"
  24. }
  25. ],
  26. "_id": "5a5de3689884c039403f9b90",
  27. "name": "xhcroom",
  28. "canuse": true
  29. },
  30. {
  31. "group": [
  32. {
  33. "_id": "5a5dd67a42d47c0528421ac1",
  34. "account": "1031568754",
  35. "name": "user2"
  36. }
  37. ],
  38. "_id": "5a5ed74ba099073b68b258b8",
  39. "name": "room4",
  40. "canuse": true
  41. }
  42. ]

1.4 用户向房间发送消息 (user)

post
/api/msgtoroom

  1. Input
  2. {
  3. "roomid": "5a5de3689884c039403f9b90",
  4. "content": "ddd"
  5. }

1.5 向用户发送消息 (user)

post
/api/msgtouser

  1. Input
  2. {
  3. "to": "5a618fdaf1ee3d37c8108c02",
  4. "content": "正文"
  5. }

1.6 读取消息 (user)

get
/api/msg

  1. 例: "/api/msg"
  2. Output
  3. "msglist": [
  4. {
  5. "_id": "5a6186ade355f73854eac66d",
  6. "from": "5a5dd67a42d47c0528421ac1",
  7. "content": "不在",
  8. "time": "2018-01-19T05:48:29.657Z",
  9. "roomid": "5a5ed74ba099073b68b258b8"
  10. },
  11. {
  12. "_id": "5a6189a41f6687189c9f0a57",
  13. "from": "5a5dd67a42d47c0528421ac1",
  14. "content": "ddd",
  15. "time": "2018-01-19T06:01:08.893Z",
  16. "roomid": null
  17. }
  18. ]

1.7 消息已读 (user)

delete
/api/readmsg

  1. Input
  2. {
  3. "time": "2018-01-19T08:29:44.092Z"
  4. }
  5. 1. 查找所有小于等于time,且to中含有该userid的记录
  6. 2. to中移除userid
  7. 3. 若移除后to为空数组,则删除该记录

1.8 用户登录 (user)

post
/api/login

  1. Input
  2. {
  3. "account": "1031568754",
  4. "password": "151136"
  5. "platform": "ios" //"ios" or "android"
  6. }
  7. Output
  8. {
  9. "err": 0,
  10. "data": {
  11. "_id": "5a66b1a63db49c09845bc8df",
  12. "account": "20180123",
  13. "name": "bbb",
  14. "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhNjZiMWE2M2RiNDljMDk4NDViYzhkZiIsImlhdCI6MTUxNjY5MzM5OCwiZXhwIjoxNTE2Njk2OTk4fQ.HGMH1WiQHYw7XftAbBCpgjnlHzRwa4gM2VgbyVV2QOg"
  15. "notification": true
  16. }
  17. }

1.9 获取用户信息 (user)

get
/api/userinfo/:id

  1. 例: "/api/userinfo:{user的_id}"
  2. Output
  3. {
  4. "err": 0,
  5. "data": {
  6. "_id": "5a618fdaf1ee3d37c8108c02",
  7. "account": "111222333",
  8. "name": "测试a",
  9. "canuse": true
  10. "notification": true
  11. }
  12. }

1.10 用户设置

put
/api/usersettings

  1. Input
  2. {
  3. "notification": true, //optional, true or false
  4. "platform": "ios" //optional, "ios" or "android"
  5. }

1.11 获取服务器时间 (无需身份验证)

get
/api/systime

  1. Output
  2. {
  3. "err": 0,
  4. "data": {
  5. "time": "2018-01-19T08:29:44.092Z"
  6. }
  7. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注