目录

最近会话列表

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

参数列表

Variable Meanings
$appId 小米开放平台申请的AppId
$appKey 小米开放平台申请的AppKey
$appSecret 小米开放平台申请的AppSecret
$appAccount 查询方在APP帐号系统内唯一ID
$token 查询方的token(使用user.getToken()获取)
$member 与查询方进行会话的用户在APP帐号系统内唯一ID
$topicId 与查询方进行会话的群在APP帐号系统内唯一ID
$sequence sequence主要用来做消息的排序和去重,全局唯一
$extra 会话的扩展字段,用于实现一些自定义功能

获取最近会话列表

  • 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"
              }
          },
          {
              "userType":"TOPIC",
              "id":"$topicId2",
              "name":"$topicName2",
              "timestamp":"$ts2",
              "extra":"$extra",
              "lastMessage":{
                  "fromUuid":"$fromUuid2",
                  "fromAccount":"$fromAccount2",
                  "payload":"$payload2", // 需base64解码
                  "sequence":"$sequence2"
              }
          },
          {
              "userType":"USER",
              "id":"$uuid1",
              "name":"$appAccount1",
              "timestamp":"$ts3",
              "extra":"$extra",
              "lastMessage":{
                  "fromUuid":"$fromUuid3",
                  "fromAccount":"$fromAccount3",
                  "payload":"$payload3", // 需base64解码
                  "sequence":"$sequence3"
              }
          }
      ],
      "message":"success"
    }
    

删除指定单聊会话

  • HTTP 请求
    curl "https://mimc.chat.xiaomi.net/api/contact/p2p/session?member=$member" -XDELETE
    -H "token:$token"
    -H "Content-Type: application/json"
    
  • JSON结果
    同上,即与获取最近会话列表的JSON结果一致。
    

删除指定群聊会话

  • HTTP 请求
    curl "https://mimc.chat.xiaomi.net/api/contact/p2t/session?topicId=$topicId" -XDELETE
    -H "token:$token"
    -H "Content-Type: application/json"
    
  • JSON结果
    同上,即与获取最近会话列表的JSON结果一致。
    

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

   curl "https://mimc.chat.xiaomi.net/api/contact/p2p/extra/" -XPOST 
   -d '{"fromId":"$fromId","toId":"$toId","extra":"$extra"}' 
   -H "appId:$appId" 
   -H "appKey:$appkey" 
   -H "appSecret:$appSecret" 
   -H "Content-Type: application/json"
   curl "https://mimc.chat.xiaomi.net/api/contact/p2p/extra/" -XPOST 
   -d '{"fromId":"$fromId","toId":"$toId","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"
             }
      }
    }
    

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

   curl "https://mimc.chat.xiaomi.net/api/contact/p2t/extra/" -XPOST 
   -d '{"topicId":"$topicId","uuid":"$uuid","extra":"$extra"}' 
   -H "appId:$appId" 
   -H "appKey:$appkey" 
   -H "appSecret:$appSecret" 
   -H "Content-Type: application/json"
   curl "https://mimc.chat.xiaomi.net/api/contact/p2p/extra/" -XPOST 
   -d '{"topicId":"$topicId","uuid":"$uuid","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"
             }
      }
    }
    

results matching ""

    No results matching ""