用户关系

1. 设置用户好友关系

设置为好友和取消好友是双向关系

1.0.1. 地址

http://domain:18080/admin/friend/status

1.0.2. body

参数 类型 必需 描述
userId string 是 用户ID
friendUid string 是 对方ID
status int 是 双方关系,0为好友,1为陌生人

好友关系与黑名单关系是分开的,如果处理黑名单请用黑名单接口

1.0.3. 响应

N/A

1.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"a\",\"friendUid\":\"b\",\"status\":0}" http://localhost:18080/admin/friend/status

{
  "code":0,
  "msg":"success",
}

2. 获取好友列表

2.0.1. 地址

http://domain:18080/admin/friend/list

2.0.2. body

参数 类型 必需 描述
userId string 是 用户ID

2.0.3. 响应

N/A

2.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"a\"}" http://localhost:18080/admin/friend/status

{
  "code":0,
  "msg":"success",
  "result":[
    "b"
  ]
}

3. 设置黑名单

设置为黑名单是单向关系

3.0.1. 地址

http://domain:18080/admin/blacklist/status

3.0.2. body

参数 类型 必需 描述
userId string 是 用户ID
targetUid string 是 对方ID
status int 是 双方关系,1为取消黑名单,2为设置为黑名单

3.0.3. 响应

N/A

3.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"a\",\"targetUid\":\"b\",\"status\":1}" http://localhost:18080/admin/blacklist/status

{
  "code":0,
  "msg":"success",
}

3.0.5. 获取黑名单列表

3.0.6. 地址

http://domain:18080/admin/blacklist/list

3.0.7. body

参数 类型 必需 描述
userId string 是 用户ID

3.0.8. 响应

N/A

3.0.9. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"a\"}" http://localhost:18080/admin/blacklist/status

{
  "code":0,
  "msg":"success",
  "result":[
    "b"
  ]
}

4. 设置备注

设置某个用户对另外一个用户的备注名,比如用户A设置用户B的备注名为“领导”

4.0.1. 地址

http://domain:18080/admin/friend/set_alias

4.0.2. body

参数 类型 必需 描述
operator string 是 用户ID
targetId string 是 对方ID
alias string 否 备注名

4.0.3. 响应

N/A

4.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"operator\":\"a\",\"targetId\":\"b\",\"alias\":\"Mr.Hello\"}" http://localhost:18080/admin/friend/set_alias

{
  "code":0,
  "msg":"success"
}

4.0.5. 获取备注

4.0.6. 地址

http://domain:18080/admin/friend/get_alias

4.0.7. body

参数 类型 必需 描述
operator string 是 用户ID
targetId string 是 用户ID

4.0.8. 响应

参数 类型 必需 描述
operator string 是 操作者
targetId string 是 目标用户
alias string 是 备注

4.0.9. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"operator\":\"a\",\"targetId\":\"a\"}" http://localhost:18080/admin/friend/get_alias

{
  "code":0,
  "msg":"success",
  "result":{
      "operator":"a",
      "targetId":"b",
      "alias":"Mr.Hello"
  }
}

5. 设置好友附加信息

设置某个用户对另外一个用户的附加信息,用于扩展各种业务能力

5.0.1. 地址

http://domain:18080/admin/friend/set_extra

5.0.2. body

参数 类型 必需 描述
operator string 是 用户ID
targetId string 是 对方ID
extra string 否 附加信息

5.0.3. 响应

N/A

5.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"operator\":\"a\",\"targetId\":\"b\",\"extra\":\"{jsonstring}\"}" http://localhost:18080/admin/friend/set_extra

{
  "code":0,
  "msg":"success"
}

6. 发送好友请求

6.0.1. 地址

http://domain:18080/admin/friend/send_request

6.0.2. body

参数 类型 必需 描述
userId string 是 用户ID
friendUid string 是 对方ID
reason string 是 附加信息
force bool 否 是否强制,false时会作为普通用户发出请求,可能受限与请求次数、请求间隔、拉黑等操作。true突破所有的限制

6.0.3. 响应

N/A

6.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"a\",\"friendUid\":\"b\",\"reason\":\"hello\",\"force\":true}" http://localhost:18080/admin/friend/send_request

{
  "code":0,
  "msg":"success"
}

6.0.5. 获取两个用户之间的所有关系

6.0.6. 地址

http://domain:18080/admin/relation/get

6.0.7. body

参数 类型 必需 描述
first string 是 用户ID
second string 是 目标用户

6.0.8. 响应

参数 类型 必需 描述
userId string 是 操作者
targetId string 是 目标用户
alias string 否 备注
extra string 否 附加信息
isFriend bool 否 是否是好友
isBlacked bool 否 是否是拉黑

6.0.9. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"operator\":\"a\",\"targetId\":\"a\"}" http://localhost:18080/admin/relation/get

{
  "code":0,
  "msg":"success",
  "result":{
      "userId":"a",
      "targetId":"b",
      "alias":"Mr.Hello",
      "isFriend":true
  }
}
2018 © wildfirechat.net 京ICP备18060403号-1 all right reserved,powered by Gitbook该文件修订时间: 2025-04-05 11:13:01

results matching ""

    No results matching ""