• 群组管理
    • 参数列表
      • 备注:
    • 人数上限
    • 创建群
      • 如下为$ownerAccount创建群
    • 查询指定群信息
      • 如下为$userAccount1查询群信息
    • 查询所属群信息
      • 如下为$userAccount1查询加入的所有群信息
    • 邀请用户加入群
      • 如下为$userAccount1邀请$userAccount4,$userAccount5加入群
    • 非群主用户退群
      • 如下为$userAccount1退群
    • 群主踢用户退群
      • 如下为$ownerAccount踢$userAccount4,$userAccount5退出群
    • 群主更新群信息
      • 如下为$ownerAccount更新群信息:群主为$userAccount2,群名称为$newTopicName,群公告为$newBulletin,也可只对某一项修改,如群名称,其它项不传数据即可。
    • 群主销毁群
      • 如下为群主销毁群

    群组管理

    参数列表

    Variable Meanings
    $appId 小米开放平台申请的AppId
    $appKey 小米开放平台申请的AppKey
    $appSecret 小米开放平台申请的AppSecret
    $topicId 表示群ID
    $topicName 表示创建群的时候所指定的群名称
    $topicId1 表示查询所属群信息时用户所加入群的群ID
    $topicId2 表示查询所属群信息时用户所加入群的群ID
    $topicName1 表示查询所属群信息时用户所加入群的群名称
    $topicName2 表示查询所属群信息时用户所加入群的群名称
    $topicBulletin1 表示查询所属群信息时用户所加入群的群公告
    $topicBulletin2 表示查询所属群信息时用户所加入群的群公告
    $newBulletin 表示更新群时设置的新群公告
    $newTopicName 表示更新群时设置的新群名称
    $ownerUuid 表示群主在MIMC帐号系统内uuid(使用user.getUuid()获取)
    $ownerAccount 表示群主在APP帐号系统内唯一ID
    $ownerToken 表示群主token(使用user.getToken()获取)
    $userAccount1 表示群成员1号在APP帐号系统内唯一ID
    $userAccount2 表示群成员2号在APP帐号系统内唯一ID
    $userAccount3 表示群成员3号在APP帐号系统内唯一ID
    $userAccount4 表示群成员4号在APP帐号系统内唯一ID
    $userAccount5 表示群成员5号在APP帐号系统内唯一ID
    $userUuid1 表示userAccount1在MIMC帐号系统内uuid(使用user.getUuid()获取)
    $userToken1 表示userAccount1的token(使用user.getToken()获取)

    备注:

    1. token的获取使用User.getToken()方法。
    2. uuid的获取使用User.getUuid()方法,uuidMIMC根据($appId, $appAccount)生成,全局唯一。
    3. 身份认证有两种方式:1. token$ownerToken/$userToken1); 2. app信息,app帐号($appKey$appSecret$ownerAccount/$userAccount1)。
    4. 当两种认证信息都存在时,优先验证前者。前者一般用于app客户端,后者一般用于app服务端。下面给出了这两种的使用方式。

    人数上限

    1. 当前群默认限制500

    创建群

    如下为$ownerAccount创建群

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId" -XPOST
    2. -d '{"topicName":$topicName,"accounts":"$userAccount1,$userAccount2,$userAccount3"}'
    3. -H "Content-Type: application/json"
    4. -H "token:$ownerToken"
    5. curl "https://mimc.chat.xiaomi.net/api/topic/$appId" -XPOST
    6. -d '{"topicName":$topicName,"accounts":"$userAccount1,$userAccount2,$userAccount3"}'
    7. -H "Content-Type: application/json"
    8. -H "appKey:$appKey"
    9. -H "appSecret:$appSecret"
    10. -H "appAccount:$ownerAccount"
    • JSON结果
    1. {
    2. "code":200,"message":"success",
    3. "data":{
    4. "topicInfo":{
    5. "topicId":$topicId,
    6. "ownerUuid":$ownerUuid,
    7. "ownerAccount":$ownerAccount,
    8. "topicName":$topicName,
    9. "bulletin":""
    10. },
    11. "members":[
    12. {"uuid":$ownerUuid,"account":$ownerAccount},
    13. {"uuid":$userUuid1,"account":$userAccount1},
    14. {"uuid":$userUuid2,"account":$userAccount2},
    15. {"uuid":$userUuid3,"account":$userAccount3}
    16. ]
    17. }
    18. }

    查询指定群信息

    如下为$userAccount1查询群信息

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId" -XGET
    2. -H "Content-Type: application/json"
    3. -H "token:$userToken1"
    4. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId" -XGET
    5. -H "Content-Type: application/json"
    6. -H "appKey:$appKey"
    7. -H "appSecret:$appSecret"
    8. -H "appAccount:$userAccount1"
    • JSON结果
    1. {
    2. "code":200,"message":"success",
    3. "data":{
    4. "topicInfo":{
    5. "topicId":$topicId,
    6. "ownerUuid":$ownerUuid,
    7. "ownerAccount":$ownerAccount,
    8. "topicName":$topicName,
    9. "bulletin":""
    10. },
    11. "members":[
    12. {"uuid":$ownerUuid,"account":$ownerAccount},
    13. {"uuid":$userUuid1,"account":$userAccount1},
    14. {"uuid":$userUuid2,"account":$userAccount2},
    15. {"uuid":$userUuid3,"account":$userAccount3}
    16. ]
    17. }
    18. }

    查询所属群信息

    如下为$userAccount1查询加入的所有群信息

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/account" -XGET
    2. -H "Content-Type: application/json"
    3. -H "token:$userToken1"
    4. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/account" -XGET
    5. -H "Content-Type: application/json"
    6. -H "appKey:$appKey"
    7. -H "appSecret:$appSecret"
    8. -H "appAccount:$userAccount1"
    • JSON结果
    1. {
    2. "code":200,
    3. "message":"success",
    4. "data":[
    5. {
    6. "topicId":$topicId1,
    7. "ownerUuid":$ownerUuid,
    8. "ownerAccount":$ownerAccount,
    9. "topicName":$topicName1,
    10. "bulletin":$topicBulletin1
    11. },
    12. {
    13. "topicId":$topicId2,
    14. "ownerUuid":$ownerUuid,
    15. "ownerAccount":$ownerAccount,
    16. "topicName":$topicName2,
    17. "bulletin":$topicBulletin2
    18. }
    19. ]
    20. }

    邀请用户加入群

    如下为$userAccount1邀请$userAccount4,$userAccount5加入群

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId/accounts" -XPOST
    2. -d '{"accounts":"$userAccount4,$userAccount5"}'
    3. -H "Content-Type: application/json"
    4. -H "token:$userToken1"
    5. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId/accounts" -XPOST
    6. -d '{"accounts":"$userAccount4,$userAccount5"}'
    7. -H "Content-Type: application/json"
    8. -H "appKey:$appKey"
    9. -H "appSecret:$appSecret"
    10. -H "appAccount:$userAccount1"
    • JSON结果
    1. {
    2. "code":200,"message":"success",
    3. "data":{
    4. "topicInfo":{
    5. "topicId":$topicId,
    6. "ownerUuid":$ownerUuid,
    7. "ownerAccount":$ownerAccount,
    8. "topicName":$topicName,
    9. "bulletin":""
    10. },
    11. "members":[
    12. {"uuid":$ownerUuid,"account":$ownerAccount},
    13. {"uuid":$userUuid1,"account":$userAccount1},
    14. {"uuid":$userUuid2,"account":$userAccount2},
    15. {"uuid":$userUuid3,"account":$userAccount3},
    16. {"uuid":$userUuid4,"account":$userAccount4},
    17. {"uuid":$userUuid5,"account":$userAccount5}
    18. ]
    19. }
    20. }

    非群主用户退群

    如下为$userAccount1退群

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId/account" -XDELETE
    2. -H "Content-Type: application/json"
    3. -H "token:$userToken1"
    4. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId/account" -XDELETE
    5. -H "Content-Type: application/json"
    6. -H "appKey:$appKey"
    7. -H "appSecret:$appSecret"
    8. -H "appAccount:$userAccount1"
    • JSON结果
    1. {"code":200,"message":"success","data":null}
    • 若是群主退群,则JSON结果如下:
    1. {"code":500,"message":"quit topic fail","data":null}

    群主踢用户退群

    如下为$ownerAccount踢$userAccount4,$userAccount5退出群

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId/accounts?accounts=$userAccount4,$userAccount5" -XDELETE
    2. -H "Content-Type: application/json"
    3. -H "token:$ownerToken"
    4. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId/accounts?accounts=$userAccount4,$userAccount5" -XDELETE
    5. -H "Content-Type: application/json"
    6. -H "appKey:$appKey"
    7. -H "appSecret:$appSecret"
    8. -H "appAccount:$ownerAccount"
    • JSON结果
    1. {
    2. "code":200,"message":"success",
    3. "data":{
    4. "topicInfo":{
    5. "topicId":$topicId,
    6. "ownerUuid":$ownerUuid,
    7. "ownerAccount":$ownerAccount,
    8. "topicName":$topicName,
    9. "bulletin":""
    10. },
    11. "members":[
    12. {"uuid":$ownerUuid,"account":$ownerAccount},
    13. {"uuid":$userUuid2,"account":$userAccount2},
    14. {"uuid":$userUuid3,"account":$userAccount3}
    15. ]
    16. }
    17. }

    群主更新群信息

    如下为$ownerAccount更新群信息:群主为$userAccount2,群名称为$newTopicName,群公告为$newBulletin,也可只对某一项修改,如群名称,其它项不传数据即可。

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId" -XPUT
    2. -d '{"ownerAccount":$userAccount2,"topicName":$newTopicName,"bulletin":$newBulletin}'
    3. -H "Content-Type: application/json"
    4. -H "token:$ownerToken"
    5. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId" -XPUT
    6. -d '{"ownerAccount":$userAccount2,"topicName":$newTopicName,"bulletin":$newBulletin}'
    7. -H "Content-Type: application/json"
    8. -H "appKey:$appKey"
    9. -H "appSecret:$appSecret"
    10. -H "appAccount:$ownerAccount"
    • JSON结果
    1. {
    2. "code":200,"message":"success",
    3. "data":{
    4. "topicInfo":{
    5. "topicId":$topicId,
    6. "ownerUuid":$userUuid2,
    7. "ownerAccount":$userAccount2,
    8. "topicName":$newTopicName,
    9. "bulletin":$newBulletin
    10. },
    11. "members":[
    12. {"uuid":$ownerUuid,"account":$ownerAccount},
    13. {"uuid":$userUuid2,"account":$userAccount2},
    14. {"uuid":$userUuid3,"account":$userAccount3}
    15. ]
    16. }
    17. }

    群主销毁群

    如下为群主销毁群

    • HTTPS请求
    1. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId" -XDELETE
    2. -H "Content-Type: application/json"
    3. -H "token:$ownerToken"
    4. curl "https://mimc.chat.xiaomi.net/api/topic/$appId/$topicId" -XDELETE
    5. -H "Content-Type: application/json"
    6. -H "appKey:$appKey"
    7. -H "appSecret:$appSecret"
    8. -H "appAccount:$ownerAccount"
    • JSON结果
    1. {"code":200,"message":"success!","data":null}