目录

最近会话列表

该功能应用于新设备登录后获取服务端存储的最近30天的全量通讯列表记录,返回结果中包括最近联系的用户和群组信息,按时间降序排列。身份验证方式即客户端使用的token验证。

参数列表

Variable Meanings
$appId 小米开放平台申请的AppId
$appKey 小米开放平台申请的AppKey
$appSecret 小米开放平台申请的AppSecret
$appAccount 查询方在APP帐号系统内唯一ID
$token 查询方的token(使用user.getToken()获取)
$member 与查询方进行会话的用户在APP帐号系统内唯一ID
$raw 会话条数
$timestamp 创建时间
$topicId 与查询方进行会话的群在APP帐号系统内唯一ID
$sequence sequence主要用来做消息的排序和去重,全局唯一
$extra 会话的扩展字段,用于实现一些自定义功能
$bizType 消息的扩展字段,参考历史消息页面
$msgExtra 消息的扩展字段,参考历史消息页面
$userType 可选值USER 或者 TOPIC,代表单聊或者群聊消息
$uuid 当前用户uuid 开发者无需关心
$msgExtraFlag 消息extra扩展字段查询标记,非必填,默认不填为false

获取最近会话列表

  • HTTP 请求

    curl "https://mimc.chat.xiaomi.net/api/contact/" -XGET
    -H "token:$token"
    -H "Content-Type: application/json"
    
  • JSON结果

    {
      "code":200,
      "data":[
          {    "userType":"TOPIC",
              "id":"$topicId1",
              "name":"$topicName1",
              "timestamp":"$ts1",
              "extra":"$extra",
              "lastMessage":{
                  "fromUuid":"$fromUuid1",
                  "fromAccount":"$fromAccount1",
                  "payload":"$payload1", // 需base64解码
                  "sequence":"$sequence1",
                  "bizType":"$bizType"
              }
          },
          {
              "userType":"USER",
              "id":"$uuid1",
              "name":"$appAccount1",
              "timestamp":"$ts3",
              "extra":"$extra",
              "lastMessage":{
                  "fromUuid":"$fromUuid3",
                  "fromAccount":"$fromAccount3",
                  "payload":"$payload3", // 需base64解码
                  "sequence":"$sequence3",
                   "bizType":"$bizType"
              }
          }
      ],
      "message":"success"
    }
    
  • 注意:
    此处获取的单聊和普通群聊会话条数各不超过1000条,未支持包含超级大群会话;
    

获取最近会话列表版本二

  • HTTP 请求
    curl "https://mimc.chat.xiaomi.net/api/contact/v2" -XGET
    -d '{"msgExtraFlag":$msgExtraFlag}'
    -H "token:$token"
    -H "Content-Type: application/json"
    
  • JSON结果
{
    "code": 200,
    "message": "success",
    "data": {
        "appId": $appId,
        "appAccount": "$appAccount",
        "uuid": $uuid,
        "row": $raw,
        "timestamp": $timestamp,
        "contacts": [
            {
                "userType": "USER",
                "id": "$id",
                "name": "$name",
                "timestamp": "$timestamp",
                "extra": "$extra",
                "lastMessage": {
                    "fromUuid": "$fromUuid",
                    "fromAccount": "$fromAccount",
                    "payload": "$payload ",
                    "sequence": "$sequence",
                    "bizType": "$bizType",
                    "msgExtra":$msgExtra // msgExtraFlag=true时会有该字段
                }
            },
            {
                "userType": "TOPIC",
                 "id": "$id",
                 "name": "$name",
                 "timestamp": "$timestamp",
                 "extra": "$extra",
                      "lastMessage": {
                      "fromUuid": "$fromUuid",
                      "fromAccount": "$fromAccount",
                      "payload": "$payload ",
                      "sequence": "$sequence",
                      "bizType": "$bizType",
                      "msgExtra":$msgExtra
                  }
            }
        ]
    }
}
  • 注意:
    此处获取的单聊和普通群聊会话条数各不超过1000条,未支持包含超级大群会话;
    

更新指定单聊会话扩展字段

   curl "https://mimc.chat.xiaomi.net/api/contact/p2p/extra/update" -XPOST
   -d '{"account":"$account","extra":"$extra"}'
   -H "token:$token"
   -H "Content-Type: application/json"
  • JSON结果
     {
         "code": 200,
         "message": "success",
         "data": {
               "userType":"USER",
                "id":"$uuid1",
                "name":"$appAccount1",
                "timestamp":"$ts3",
                "extra":"$extra",
                "lastMessage":{
                    "fromUuid":"$fromUuid3",
                     "fromAccount":"$fromAccount3",
                     "payload":"$payload3", // 需base64解码
                     "sequence":"$sequence3",
                     "bizType":"$bizType"
                }
         }
     }
    

更新指定群聊会话扩展字段

   curl "https://mimc.chat.xiaomi.net/api/contact/p2t/extra/update" -XPOST
   -d '{"topicId":"$topicId","extra":"$extra"}'
   -H "token:$token"
   -H "Content-Type: application/json"
  • JSON结果
     {
         "code": 200,
         "message": "success",
         "data": {
               "userType":"TOPIC",
                "id":"$uuid1",
                "name":"$appAccount1",
                "timestamp":"$ts3",
                "extra":"$extra",
                "lastMessage":{
                    "fromUuid":"$fromUuid3",
                     "fromAccount":"$fromAccount3",
                     "payload":"$payload3", // 需base64解码
                     "sequence":"$sequence3",
                     "bizType":"$bizType"
                }
         }
     }
    
  • 注意
    更新会话extra是指,更新当前token解析出的用户和某个accout或者topicId之间的会话
    

回到顶部

results matching ""

    No results matching ""