网易云信Server Http API接口文档

接口概述

API调用说明

本文档中,所有调用云信服务端接口的请求都需要按此规则校验。

API checksum校验

以下参数需要放在Http Request Header中

参数 参数说明
AppKey 开发者平台分配的appkey
Nonce 随机数(最大长度128个字符)
CurTime 当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的秒数(String)
CheckSum SHA1(AppSecret + Nonce + CurTime),三个参数拼接的字符串,进行SHA1哈希计算,转化成16进制字符(String,小写)

CheckSum有效期:出于安全性考虑,每个checkSum的有效期为5分钟(用CurTime计算),建议每次请求都生成新的checkSum,同时请确认发起请求的服务器是与标准时间同步的,比如有NTP服务。
CheckSum检验失败时会返回414错误码,具体参看code状态表。
重要提示: 本文档中提供的所有接口均面向开发者服务器端调用,用于计算CheckSum的AppSecret开发者应妥善保管,可在应用的服务器端存储和使用,但不应存储或传递到客户端,也不应在网页等前端代码中嵌入。

计算CheckSum的java代码举例如下:

import java.security.MessageDigest;

public class CheckSumBuilder {
    // 计算并获取CheckSum
    public static String getCheckSum(String appSecret, String nonce, String curTime) {
        return encode("sha1", appSecret + nonce + curTime);
    }

    // 计算并获取md5值
    public static String getMD5(String requestBody) {
        return encode(“md5”, requestBody);
    }

    private static String encode(String algorithm, String value) {
        if (value == null) {
            return null;
        }
        try {
            MessageDigest messageDigest
                    = MessageDigest.getInstance(algorithm);
            messageDigest.update(value.getBytes());
            return getFormattedText(messageDigest.digest());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    private static String getFormattedText(byte[] bytes) {
        int len = bytes.length;
        StringBuilder buf = new StringBuilder(len * 2);
        for (int j = 0; j < len; j++) {
            buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
            buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
        }
        return buf.toString();
    }
    private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
}

接口说明

  1. 所有接口都只支持POST请求;
  2. 所有接口请求Content-Type类型为:application/x-www-form-urlencoded;charset=utf-8;
  3. 所有接口返回类型为JSON,同时进行UTF-8编码。

接口示例

云信服务端接口是简单的http接口,适配各种语言。 当然我们也提供了一些简单的示例供开发者参考。 云信服务器接口示例

云信ID

云信ID调用说明

  1. App:第三方app客户端;
  2. AppServer:第三方app服务端;
  3. 云信webserver:云信后台web服务;
  4. 云信imserver:SDK直连的IM服务。 Alt text

    注:

    1. 客户端通过云信SDK连接服务器时,需要保证云信ID已经注册,通过云信webserver生成token,确保客户端从服务器已经取得token;
    2. 客户端在获取token之后,可以直连云信服务器,进行校验;
    3. token:云信ID的密码
      • 创建云信ID时如果第三方APP自己指定,可以为加密后的密码,也可以为第三方为帐号生成的一个加密的密钥,此密钥在创建云信ID时指定,在app直连云信imserver时带上即可,此密钥在第三方被修改时,请同步在云信webserver进行修改,以免引起用户登陆失败;
      • 创建云信ID时如果不指定此密钥,则云信会为该ID生成一个加密的密钥,第三方需要保存此密钥,app在登录时需要进行认证,并且在云信imserver进行连接时,需要带上此密钥,此密钥第三方也可以进行修改,同时也需要在修改时同步到云信webserver中(此密钥原则上没有过期时间,如果发现密钥丢失可以使用接口刷新密钥);
    4. 云信ID,以下文档中也称为“用户帐号”,参数名用“accid”表示。

创建云信ID

请求说明

POST https://api.netease.im/nimserver/user/create.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.第三方帐号导入到云信平台;

2.注意accid,name长度以及考虑管理token。

参数说明

参数类型必须说明
accidString 云信ID,最大长度32字符,必须保证一个
APP内唯一(只允许字母、数字、半角下划线_、
@、半角点以及半角-组成,不区分大小写,
会统一小写处理,请注意以此接口返回结果中的accid为准)。
nameString 云信ID昵称,最大长度64字符,用来PUSH推送
时显示的昵称
propsString json属性,第三方可选填,最大长度1024字符
iconString 云信ID头像URL,第三方可选填,最大长度1024
tokenString 云信ID可以指定登录token值,最大长度128字符,
并更新,如果未指定,会自动生成token,并在
创建成功后返回

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&name=zhangsan' 'https://api.netease.im/nimserver/user/create.action'

HttpClient请求示例(以下各接口的HttpClient调用方式参考此处

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Test {
    public static void main(String[] args) throws Exception{
        DefaultHttpClient httpClient = new DefaultHttpClient();
        String url = "https://api.netease.im/nimserver/user/create.action";
        HttpPost httpPost = new HttpPost(url);

        String appKey = "94kid09c9ig9k1loimjg012345123456";
        String appSecret = "123456789012";
        String nonce =  "12345";
        String curTime = String.valueOf((new Date()).getTime() / 1000L);
        String checkSum = CheckSumBuilder.getCheckSum(appSecret, nonce ,curTime);//参考 计算CheckSum的java代码

        // 设置请求的header
        httpPost.addHeader("AppKey", appKey);
        httpPost.addHeader("Nonce", nonce);
        httpPost.addHeader("CurTime", curTime);
        httpPost.addHeader("CheckSum", checkSum);
        httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");

        // 设置请求的参数
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("accid", "helloworld"));
        httpPost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));

        // 执行请求
        HttpResponse response = httpClient.execute(httpPost);

        // 打印执行结果
        System.out.println(EntityUtils.toString(response.getEntity(), "utf-8"));
    }
}

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "info":{"token":"xx","accid":"xx","name":"xx"} 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


云信ID更新

请求说明

POST https://api.netease.im/nimserver/user/update.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

云信ID基本信息更新

参数说明

参数类型必须说明
accidString 云信ID,最大长度32字符,必须保证一个
APP内唯一
propsString json属性,第三方可选填,最大长度1024字符
tokenString 云信ID可以指定登录token值,最大长度128字符

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api.netease.im/nimserver/user/update.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


更新并获取新token

请求说明

POST https://api.netease.im/nimserver/user/refreshToken.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.webserver更新云信ID的token,同时返回新的token;

2.一般用于云信ID修改密码,找回密码或者第三方有需求获取新的token。

参数说明


参数类型必须说明
accidString 云信ID,最大长度32字符,必须保证一个
APP内唯一

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api.netease.im/nimserver/user/refreshToken.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200, 
  "info":{"token":"xxx","accid":"xx" } 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


封禁云信ID

请求说明

POST https://api.netease.im/nimserver/user/block.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.第三方禁用某个云信ID的IM功能;

2.封禁云信ID后,此ID将不能登陆云信imserver。

参数说明

参数类型必须说明
accidString 云信ID,最大长度32字符,必须保证一个
APP内唯一
needkick String 是否踢掉被禁用户,true或false,默认false

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api.netease.im/nimserver/user/block.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


解禁云信ID

请求说明

POST https://api.netease.im/nimserver/user/unblock.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

解禁被封禁的云信ID

参数说明

参数类型必须说明
accidString 云信ID,最大长度32字符,必须保证一个
APP内唯一

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api.netease.im/nimserver/user/unblock.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


用户名片

更新用户名片

请求说明

POST https://api.netease.im/nimserver/user/updateUinfo.action  HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

更新用户名片

参数说明

参数类型必须说明
accidString 用户帐号,最大长度32字符,必须保证一个APP内唯一
name String 用户昵称,最大长度64字符
icon String 用户icon,最大长度1024字符
sign String 用户签名,最大长度256字符
email String 用户email,最大长度64字符
birth String 用户生日,最大长度16字符
mobile String 用户mobile,最大长度32字符,只支持国内号码
gender int 用户性别,0表示未知,1表示男,2女表示女,其它会报参数错误
ex String 用户名片扩展字段,最大长度1024字符,用户可自行扩展,建议封装成JSON字符串

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&name=Jack' 'https://api.netease.im/nimserver/user/updateUinfo.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


获取用户名片

请求说明

POST https://api.netease.im/nimserver/user/getUinfos.action  HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

获取用户名片,可批量

参数说明

参数类型必须说明
accids String 用户帐号(例如:JSONArray对应的accid串,如:["zhangsan"],如果解析出错,会报414)(一次查询最多为200)

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accids=["zhangsan"]' 'https://api.netease.im/nimserver/user/getUinfos.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "uinfos":
     [
      {"email":"t1@163.com","accid":"t1","name":"abc","gender":1,"mobile":"18645454545"},
      {"accid":"t2","name":"def","gender":0}
     ]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


用户设置

设置桌面端在线时,移动端是否需要推送

请求说明

POST https://api.netease.im/nimserver/user/setDonnop.action  HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

设置桌面端在线时,移动端是否需要推送

参数说明

参数类型必须说明
accidString 用户帐号
donnopOpen String 桌面端在线时,移动端是否不推送:
true:移动端不需要推送,false:移动端需要推送

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&donnopOpen=true'  'https://api.netease.im/nimserver/user/setDonnop.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


用户关系托管

好友关系

接口描述

1.两人保持好友关系

参数说明

参数类型必须说明
accidString 加好友发起者accid
faccidString 加好友接收者accid
typeint 1直接加好友,2请求加好友,3同意加好友,4拒绝加好友
msgString 加好友对应的请求消息,第三方组装,最长256字符

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&faccid=lisi&type=1' 'https://api.netease.im/nimserver/friend/add.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


接口描述

1.更新好友相关信息,如加备注名,必须是好友才可以

参数说明



参数类型必须说明
accidString 发起者accid
faccidString 要修改朋友的accid
aliasString 给好友增加备注名,限制长度128
ex String 修改ex字段,限制长度256

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&faccid=lisi&alias=lisi' 'https://api.netease.im/nimserver/friend/update.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


请求中Headers的设置请参考接口概述

接口描述

1.删除好友关系

参数说明

参数类型必须说明
accidString 发起者accid
faccidString 要删除朋友的accid

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&faccid=lisi' 'https://api.netease.im/nimserver/friend/delete.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


接口描述

1.查询某时间点起到现在有更新的双向好友

参数说明

参数类型必须说明
accidString 发起者accid
createtimeString 查询的时间点

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&createtime=1443599631111' 'https://api.netease.im/nimserver/friend/get.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
    "code":200,
    "size":2,
    "friends":
    [
      {"createtime":1440037706987,"bidirection":true,"faccid":"t2"},
      {"createtime":1440037718190,"bidirection":true,"faccid":"t3","alias":"t3"}
    ]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


黑名单/静音

请求说明

POST https://api.netease.im/nimserver/user/setSpecialRelation.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

拉黑/取消拉黑;设置静音/取消静音

参数说明

参数类型必须说明
accidString 用户帐号,最大长度32字符,必须保证一个
APP内唯一
targetAccString 被加黑或加静音的帐号
relationTypeint 本次操作的关系类型,1:黑名单操作,2:静音列表操作
valueint 操作值,0:取消黑名单或静音,1:加入黑名单或静音

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&targetAcc=lisi&relationType=1&value=0' 'https://api.netease.im/nimserver/user/setSpecialRelation.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


请求说明

POST https://api.netease.im/nimserver/user/listBlackAndMuteList.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

查看用户的黑名单和静音列表

参数说明

参数类型必须说明
accidString 用户帐号,最大长度32字符,必须保证一个
APP内唯一

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api.netease.im/nimserver/user/listBlackAndMuteList.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "mutelist": [    //被静音的帐号列表
    "abc",
    "cde"
  ],
  "blacklist": [    //加黑的帐号列表
    "abc"
  ],
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


消息功能

发送普通消息

请求说明

POST https://api.netease.im/nimserver/msg/sendMsg.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

给用户或者群发送普通消息,包括文本,图片,语音,视频和地理位置,具体消息参考下面描述

参数说明

参数类型必须说明
fromString 发送者accid,用户帐号,最大32字符,
必须保证一个APP内唯一
opeint 0:点对点个人消息,1:群消息,其他返回414
toString ope==0是表示accid即用户id,ope==1表示tid即群id
typeint 0 表示文本消息,
1 表示图片,
2 表示语音,
3 表示视频,
4 表示地理位置信息,
6 表示文件,
100 自定义消息类型
bodyString 请参考下方消息示例说明中对应消息的body字段,
最大长度5000字符,为一个json串
antispam String 本消息是否需要过自定义反垃圾系统,true或false, 默认false
antispamCustom String 自定义的反垃圾内容, 长度限制同body字段,不能超过5000字符
option String 发消息时特殊指定的行为选项,Json格式,可用于指定消息的漫游,存云端历史,发送方多端同步,推送,消息抄送等特殊行为;option中字段不填时表示默认值 option示例:

{"push":false,"roam":true,"history":false,"sendersync":true,"route":false,"badge":false,"needPushNick":true}

字段说明:
1. roam: 该消息是否需要漫游,默认true(需要app开通漫游消息功能);

2. history: 该消息是否存云端历史,默认true;

3. sendersync: 该消息是否需要发送方多端同步,默认true;

4. push: 该消息是否需要APNS推送或安卓系统通知栏推送,默认true;

5. route: 该消息是否需要抄送第三方;默认true (需要app开通消息抄送功能);

6. badge:该消息是否需要计入到未读计数中,默认true;
7. needPushNick: 推送文案是否需要带上昵称,不设置该参数时默认true;
8. persistent: 是否需要存离线消息,不设置该参数时默认true。
pushcontent String ios推送内容,不超过150字符,option选项中允许推送(push=true),此字段可以指定推送内容
payload String ios 推送对应的payload,必须是JSON,不能超过2k字符
ext String 开发者扩展字段,长度限制1024字符
forcepushlist String 发送群消息时的强推(@操作)用户列表,格式为JSONArray,如["accid1","accid2"]。若forcepushall为true,则forcepushlist为除发送者外的所有有效群成员
forcepushcontent String 发送群消息时,针对强推(@操作)列表forcepushlist中的用户,强制推送的内容
forcepushall String 发送群消息时,强推(@操作)列表是否为群里除发送者外的所有有效成员,true或false,默认为false

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'from=zhangsan&ope=0&to=lisi&type=0&body={"msg":"hello"}' 'https://api.netease.im/nimserver/msg/sendMsg.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


批量发送点对点普通消息

请求说明

POST https://api.netease.im/nimserver/msg/sendBatchMsg.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.给用户发送点对点普通消息,包括文本,图片,语音,视频,地理位置和自定义消息。
2.最大限500人,只能针对个人,如果批量提供的帐号中有未注册的帐号,会提示并返回给用户。
3.此接口受频率控制,一个应用一分钟最多调用120次,超过会返回416状态码,并且被屏蔽一段时间;
具体消息参考下面描述。

参数说明

参数类型必须说明
fromAccid String 发送者accid,用户帐号,最大32字符,
必须保证一个APP内唯一
toAccids String ["aaa","bbb"](JSONArray对应的accid,如果解析出错,会报414错误),限500人
typeint 0 表示文本消息,
1 表示图片,
2 表示语音,
3 表示视频,
4 表示地理位置信息,
6 表示文件,
100 自定义消息类型
bodyString 请参考下方消息示例说明中对应消息的body字段,
最大长度5000字符,为一个json串
option String 发消息时特殊指定的行为选项,Json格式,可用于指定消息的漫游,存云端历史,发送方多端同步,推送,消息抄送等特殊行为;option中字段不填时表示默认值 option示例:

{"push":false,"roam":true,"history":false,"sendersync":true,"route":false,"badge":false,"needPushNick":true}

字段说明:
1. roam: 该消息是否需要漫游,默认true(需要app开通漫游消息功能);

2. history: 该消息是否存云端历史,默认true;

3. sendersync: 该消息是否需要发送方多端同步,默认true;

4. push: 该消息是否需要APNS推送或安卓系统通知栏推送,默认true;

5. route: 该消息是否需要抄送第三方;默认true (需要app开通消息抄送功能);

6. badge:该消息是否需要计入到未读计数中,默认true;
7. needPushNick: 推送文案是否需要带上昵称,不设置该参数时默认true;
pushcontent String ios推送内容,不超过150字符,option选项中允许推送(push=true),此字段可以指定推送内容
payload String ios 推送对应的payload,必须是JSON,不能超过2k字符
ext String 开发者扩展字段,长度限制1024字符

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'fromAccid=zhangsan&toAccids=["aaa","bbb"]&type=0&body={"msg":"hello"}' 'https://api.netease.im/nimserver/msg/sendBatchMsg.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "unregister":"["a","b"...]" //未注册的帐号
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表

消息格式示例:
1.文本消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":0,//文本消息类型
    "body":{
        "msg":"哈哈哈"//消息内容
    }
}

2 图片消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":1    //图片类型消息
    "body":{
        "name":"图片发送于2015-05-07 13:59",   //图片name
        "md5":"9894907e4ad9de4678091277509361f7",    //md5
        "url":"http://nimtest.nos.netease.com/cbc500e8-e19c-4b0f-834b-c32d4dc1075e",    //生成的url
                "ext":"jpg",    //图片后缀
        "w":6814,    //宽
        "h":2332,    //高
        "size":388245    //图片大小
    }
}

3 语音消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":2    //语音类型消息
    "body":{
        "dur":4551,        //语音持续时长ms
        "md5":"87b94a090dec5c58f242b7132a530a01",    //md5
        "url":"http://nimtest.nos.netease.com/a2583322-413d-4653-9a70-9cabdfc7f5f9",    //生成的url
        "ext":"aac",        //语音消息格式,只能是aac格式
        "size":16420        //语音文件大小
    }
}

4 视频消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":3    //视频类型消息
    "body":{
        "dur":8003,        //视频持续时长ms
        "md5":"da2cef3e5663ee9c3547ef5d127f7e3e",    //md5
        "url":"http://nimtest.nos.netease.com/21f34447-e9ac-4871-91ad-d9f03af20412",    //生成的url
        "w":360,    //宽
        "h":480,    //高
        "ext":"mp4",    //视频格式
        "size":16420    //视频文件大小
    }
}

5 发送地理位置消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":4    //地理位置类型消息
    "body":{
        "title":"中国 浙江省 杭州市 网商路 599号",    //地理位置title
        "lng":120.1908686708565,        // 经度
        "lat":30.18704515647036            // 纬度
    }
}

6 发送文件消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":6    //文件消息
    "body":{
        "name":"BlizzardReg.ttf",    //文件名
        "md5":"79d62a35fa3d34c367b20c66afc2a500", //文件MD5
        "url":"http://nimtest.nos.netease.com/08c9859d-183f-4daa-9904-d6cacb51c95b", //文件URL
        "ext":"ttf",    //文件后缀类型
        "size":91680    //大小
    }
}

7 发送第三方自定义消息

{
    "from":"test1",
    "ope":0,
    "to":"test2",
    "type":100    //第三方自定义消息
    //第三方定义的body体,json串
    "body":{
        "myKey":myValue    
    }
}

发送自定义系统通知

请求说明

POST https://api.netease.im/nimserver/msg/sendAttachMsg.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.自定义系统通知区别于普通消息,方便开发者进行业务逻辑的通知;
2.目前支持两种类型:点对点类型和群类型(仅限高级群),根据msgType有所区别。

应用场景:如某个用户给另一个用户发送好友请求信息等,具体attach为请求消息体,第三方可以自行扩展,建议是json格式

参数说明


参数类型必须说明
fromString 发送者accid,用户帐号,最大32字符,APP内唯一
msgtypeint 0:点对点自定义通知,1:群消息自定义通知,其他返回414
toString msgtype==0是表示accid即用户id,msgtype==1表示tid即群id
attachString 自定义通知内容,第三方组装的字符串,建议是JSON串,最大长度4096字符
pushcontentString iOS推送内容,第三方自己组装的推送内容,不超过150字符
payloadString iOS推送对应的payload,必须是JSON,不能超过2k字符
soundString 如果有指定推送,此属性指定为客户端本地的声音文件名,长度不要超过30个字符,如果不指定,会使用默认声音
saveint 1表示只发在线,2表示会存离线,其他会报414错误。默认会存离线
option String 发消息时特殊指定的行为选项,Json格式,可用于指定消息计数等特殊行为;option中字段不填时表示默认值。
option示例:
{"badge":false,"needPushNick":false,"route":false}
字段说明:
1. badge:该消息是否需要计入到未读计数中,默认true;
2. needPushNick: 推送文案是否需要带上昵称,不设置该参数时默认false(ps:注意与sendMsg.action接口有别);
3. route: 该消息是否需要抄送第三方;默认true (需要app开通消息抄送功能)

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'from=zhangsan&msgtype=0&to=lisi&attach={"myattach":"test"}' 'https://api.netease.im/nimserver/msg/sendAttachMsg.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


批量发送点对点自定义系统通知

请求说明

POST https://api.netease.im/nimserver/msg/sendBatchAttachMsg.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.系统通知区别于普通消息,应用接收到直接交给上层处理,客户端可不做展示;
2.目前支持类型:点对点类型;
3.最大限500人,只能针对个人,如果批量提供的帐号中有未注册的帐号,会提示并返回给用户;
4.此接口受频率控制,一个应用一分钟最多调用120次,超过会返回416状态码,并且被屏蔽一段时间;

应用场景:如某个用户给另一个用户发送好友请求信息等,具体attach为请求消息体,第三方可以自行扩展,建议是json格式

参数说明


参数类型必须说明
fromAccid String 发送者accid,用户帐号,最大32字符,APP内唯一
toAccids String ["aaa","bbb"](JSONArray对应的accid,如果解析出错,会报414错误),最大限500人
attachString 自定义通知内容,第三方组装的字符串,建议是JSON串,最大长度4096字符
pushcontentString iOS推送内容,第三方自己组装的推送内容,不超过150字符
payloadString iOS推送对应的payload,必须是JSON,不能超过2k字符
soundString 如果有指定推送,此属性指定为客户端本地的声音文件名,长度不要超过30个字符,如果不指定,会使用默认声音
saveint 1表示只发在线,2表示会存离线,其他会报414错误。默认会存离线
option String 发消息时特殊指定的行为选项,Json格式,可用于指定消息计数等特殊行为;option中字段不填时表示默认值。
option示例:
{"badge":false,"needPushNick":false,"route":false}
字段说明:
1. badge:该消息是否需要计入到未读计数中,默认true;
2. needPushNick: 推送文案是否需要带上昵称,不设置该参数时默认false(ps:注意与sendBatchMsg.action接口有别)。
3. route: 该消息是否需要抄送第三方;默认true (需要app开通消息抄送功能)

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'fromAccid=zhangsan&toAccids=["aaa","bbb"]&attach={"myattach":"test"}' 'https://api.netease.im/nimserver/msg/sendBatchAttachMsg.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "unregister":"["a","b"...]" //未注册的帐号
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


文件上传

请求说明

POST https://api.netease.im/nimserver/msg/upload.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

文件上传,字符流需要base64编码,最大15M。

参数说明

参数类型必须说明
contentString 字符流base64串(Base64.encode(bytes)) ,最大15M的字符流
typeString 上传文件类型

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'content=gwettwgsgssgs323f' 'https://api.netease.im/nimserver/msg/upload.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "url":"xxx"
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


文件上传(multipart方式)

请求说明

POST https://api.netease.im/nimserver/msg/fileUpload.action HTTP/1.1
Content-Type:multipart/form-data;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

文件上传,最大15M

参数说明

参数类型必须说明
contentMultipart 最大15M的字符流
typeString 上传文件类型

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: multipart/form-data" -d 'content=gwettwgsgssgs323f' 'https://api.netease.im/nimserver/msg/fileUpload.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "url":"xxx"
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


消息撤回

请求说明

POST https://api.netease.im/nimserver/msg/recall.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

消息撤回接口,可以撤回一定时间内的点对点与群消息

参数说明

参数类型必须说明
deleteMsgid String 要撤回消息的msgid
timetag long 要撤回消息的创建时间
type int 7:表示点对点消息撤回,8:表示群消息撤回,其它为参数错误
from String 发消息的accid
to String 如果点对点消息,为接收消息的accid,如果群消息,为对应群的tid
msg String 可以带上对应的描述

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'deleteMsgid=10386192&timetag=1481528155741&type=7&from=t1&to=t4&msg=这是一条撤回消息'  'https://api.netease.im/nimserver/msg/recall.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


群组功能(高级群)

注意:所有群操作一个ip一分钟操作次数超过600次,会返回416错误码。

创建群

请求说明

POST https://api.netease.im/nimserver/team/create.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

  1. 创建高级群,以邀请的方式发送给用户;
  2. custom 字段是给第三方的扩展字段,第三方可以基于此字段扩展高级群的功能,构建自己需要的群;
  3. 建群成功会返回tid,需要保存,以便于加人与踢人等后续操作;
  4. 每个用户可创建的群数量有限制,限制值由 IM 套餐的群组配置决定,可登录管理后台查看。

参数说明

参数类型必须说明
tnameString 群名称,最大长度64字符
ownerString 群主用户帐号,最大长度32字符
membersString ["aaa","bbb"](JSONArray对应的accid,如果解析出错会报414),一次最多拉200个成员
announcementString 群公告,最大长度1024字符
introString 群描述,最大长度512字符
msgString 邀请发送的文字,最大长度150字符
magreeint 管理后台建群时,0不需要被邀请人同意加入群,1需要被邀请人同意才可以加入群。其它会返回414
joinmodeint 群建好后,sdk操作时,0不用验证,1需要验证,2不允许任何人加入。其它返回414
customString 自定义高级群扩展属性,第三方可以跟据此属性自定义扩展自己的群属性。(建议为json),最大长度1024字符
icon String 群头像,最大长度1024字符
beinvitemode int 被邀请人同意方式,0-需要同意(默认),1-不需要同意。其它返回414
invitemode int 谁可以邀请他人入群,0-管理员(默认),1-所有人。其它返回414
uptinfomode int 谁可以修改群资料,0-管理员(默认),1-所有人。其它返回414
upcustommode int 谁可以更新群自定义属性,0-管理员(默认),1-所有人。其它返回414

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tname=myteam&owner=zhangsan&members=["aaa","bbb"]&msg=welcome&magree=0&joinmode=0' 'https://api.netease.im/nimserver/team/create.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200, 
  "tid":"11001"
}

主要的返回码

200、403、414、416、431、500、801、806

具体请参考code状态表


拉人入群

请求说明

POST https://api.netease.im/nimserver/team/add.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1.可以批量邀请,邀请时需指定群主;
2.当群成员达到上限时,再邀请某人入群返回失败;
3.当群成员达到上限时,被邀请人“接受邀请"的操作也将返回失败。

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回,最大长度128字符
ownerString 群主用户帐号,最大长度32字符
membersString ["aaa","bbb"](JSONArray对应的accid,如果解析出错会报414),一次最多拉200个成员
magreeint 管理后台建群时,0不需要被邀请人同意加入群,1需要被邀请人同意才可以加入群。其它会返回414
msgString 邀请发送的文字,最大长度150字符
attach String 自定义扩展字段,最大长度512

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&members=["aaa","bbb"]&msg=welcome&magree=0' 'https://api.netease.im/nimserver/team/add.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500、801

具体请参考code状态表


踢人出群

请求说明

POST https://api.netease.im/nimserver/team/kick.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

  1. 高级群踢人出群,需要提供群主accid以及要踢除人的accid。

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回,最大长度128字符
ownerString 群主的accid,用户帐号,最大长度32字符
memberString被移除人的accid,用户账号,最大长度字符
attach String 自定义扩展字段,最大长度512

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&member=lisi' 'https://api.netease.im/nimserver/team/kick.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


解散群

请求说明

POST https://api.netease.im/nimserver/team/remove.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

删除整个群,会解散该群,需要提供群主accid,谨慎操作!

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回,最大长度128字符
ownerString 群主用户帐号,最大长度32字符

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan' 'https://api.netease.im/nimserver/team/remove.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


编辑群资料

请求说明

POST https://api.netease.im/nimserver/team/update.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

高级群基本信息修改

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回
tnameString 群名称,最大长度64字符
ownerString 群主用户帐号,最大长度32字符
announcementString 群公告,最大长度1024字符
introString 群描述,最大长度512字符
joinmodeint 群建好后,sdk操作时,0不用验证,1需要验证,2不允许任何人加入。其它返回414
customString 自定义高级群扩展属性,第三方可以跟据此属性自定义扩展自己的群属性。(建议为json),最大长度1024字符
icon String 群头像,最大长度1024字符
beinvitemode int 被邀请人同意方式,0-需要同意(默认),1-不需要同意。其它返回414
invitemode int 谁可以邀请他人入群,0-管理员(默认),1-所有人。其它返回414
uptinfomode int 谁可以修改群资料,0-管理员(默认),1-所有人。其它返回414
upcustommode int 谁可以更新群自定义属性,0-管理员(默认),1-所有人。其它返回414

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&tname=mygroup&owner=zhangsan' 'https://api.netease.im/nimserver/team/update.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


群信息与成员列表查询

请求说明

POST https://api.netease.im/nimserver/team/query.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

  1. 高级群信息与成员列表查询,一次最多查询30个群相关的信息,跟据ope参数来控制是否带上群成员列表;
  2. 查询群成员会稍微慢一些,所以如果不需要群成员列表可以只查群信息;
  3. 此接口受频率控制,某个应用一分钟最多查询30次,超过会返回416,并且被屏蔽一段时间;
  4. 群成员的群列表信息中增加管理员成员admins的返回。

参数说明

参数类型必须说明
tidsString 群id列表,如["3083","3084"]
opeint 1表示带上群成员列表,0表示不带群成员列表,只返回群信息

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tids=["3083","3084"]&ope=1' "https://api.netease.im/nimserver/team/query.action"

返回说明

http 响应:json

//查询不带群成员的群列表信息
{
  "code":200,
  "tinfos":
    [
 {"tname":"aa","announcement":"aa","owner":"v4","maxusers":50,
      "joinmode":1,"tid":3083,"intro":"test","size":3, "custom":"", "mute":true},
 {"tname":"bb","announcement":"bb","owner":"v4","maxusers":50,
      "joinmode":1,"tid":3084,"intro":"test","size":3, "custom":"", "mute":false}
    ]
}
//查询带群成员的群列表信息
{
  "code":200,
  "tinfos":
    [
      {"tname":"aa","announcement":"aa","owner":"v4","maxusers":50,
      "joinmode":1,"tid":3083,"intro":"test","size":3,"custom":"",
"mute":true, "admins":["v3"],"members":["v1","v2"]},
      {"tname":"bb","announcement":"bb","owner":"v4","maxusers":50,
      "joinmode":1,"tid":3084,"intro":"test","size":3,"custom":"",
"mute":false, "admins":["v3"],"members":["v1","v2"]}
    ]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


移交群主

请求说明

POST https://api.netease.im/nimserver/team/changeOwner.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

  1. 转换群主身份;
  2. 群主可以选择离开此群,还是留下来成为普通成员。

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回,最大长度128字符
ownerString 群主用户帐号,最大长度32字符
newownerString 新群主帐号,最大长度32字符
leaveint 1:群主解除群主后离开群,2:群主解除群主后成为普通成员。其它414

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&newowner=lisi&leave=1' 'https://api.netease.im/nimserver/team/changeOwner.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200
}

主要的返回码

200、403、414、416、431、500、806

具体请参考code状态表


任命管理员

请求说明

POST https://api.netease.im/nimserver/team/addManager.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

提升普通成员为群管理员,可以批量,但是一次添加最多不超过10个人。

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回,最大长度128字符
ownerString 群主用户帐号,最大长度32字符
membersString ["aaa","bbb"](JSONArray对应的accid,如果解析出错会报414),长度最大1024字符(一次添加最多10个管理员)

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&members=["aaa","bbb"]' 'https://api.netease.im/nimserver/team/addManager.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


移除管理员

请求说明

POST https://api.netease.im/nimserver/team/removeManager.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

解除管理员身份,可以批量,但是一次解除最多不超过10个人

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回,最大长度128字符
ownerString 群主用户帐号,最大长度32字符
membersString ["aaa","bbb"](JSONArray对应的accid,如果解析出错会报414),长度最大1024字符(一次解除最多10个管理员)

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&members=["aaa","bbb"]' 'https://api.netease.im/nimserver/team/removeManager.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


获取某用户所加入的群信息

请求说明

POST https://api.netease.im/nimserver/team/joinTeams.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

获取某个用户所加入高级群的群信息

参数说明

参数类型必须说明
accidString 要查询用户的accid

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api.netease.im/nimserver/team/joinTeams.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{   "code":200 ,
    "count":2,
    "infos":
      [
          {"owner":"t2","tname":"test1","maxusers":50,"tid":3620,"size":3, "custom":""},
          {"owner":"t1","tname":"test2","maxusers":50,"tid":3622,"size":4, "custom":""}
      ]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


修改群昵称

请求说明

POST https://api.netease.im/nimserver/team/updateTeamNick.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

修改指定账号在群内的昵称

参数说明

参数类型必须说明
tidString 群唯一标识,创建群时云信服务器产生并返回
ownerString 群主 accid
accidString 要修改群昵称的群成员 accid
nickString accid 对应的群昵称,最大长度32字符

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&accid=lisi&nick=jack' 'https://api.netease.im/nimserver/team/updateTeamNick.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


修改消息提醒开关

请求说明

POST https://api.netease.im/nimserver/team/muteTeam.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

高级群修改消息提醒开关

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回
accid String 要操作的群成员accid
ope int 1:关闭消息提醒,2:打开消息提醒,其他值无效

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=11111&accid=lisi&ope=1' 'https://api.netease.im/nimserver/team/muteTeam.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


禁言群成员

请求说明

POST https://api.netease.im/nimserver/team/muteTlist.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

高级群禁言群成员

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回
owner String 群主accid
accid String 禁言对象的accid
mute int 1-禁言,0-解禁

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&accid=wangwu&mute=1' 'https://api.netease.im/nimserver/team/muteTlist.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


主动退群

请求说明

POST https://api.netease.im/nimserver/team/leave.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

高级群主动退群

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回
accid String 退群的accid

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&accid=wangwu'  'https://api.netease.im/nimserver/team/leave.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


将群组整体禁言

请求说明

POST https://api.netease.im/nimserver/team/muteTlistAll.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

禁言群组,普通成员不能发送消息,创建者和管理员可以发送消息

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回
owner String 群主的accid
mute String true:禁言,false:解禁

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=zhangsan&mute=1'  'https://api.netease.im/nimserver/team/muteTlistAll.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


获取群组禁言列表

请求说明

POST https://api.netease.im/nimserver/team/listTeamMute.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

获取群组禁言的成员列表

参数说明

参数类型必须说明
tidString 云信服务器产生,群唯一标识,创建群时会返回
owner String 群主的accid

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=1513535&owner=wangwu'  'https://api.netease.im/nimserver/team/listTeamMute.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200, 
  "mutes":[ 
    {"nick":"nick1","accid":"user1","tid":17874,"type":0}, 
    {"nick":"nick2","accid":"user2","tid":17874,"type":0} 
  ]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


聊天室

创建聊天室

请求说明

POST https://api.netease.im/nimserver/chatroom/create.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

创建聊天室

参数说明


参数类型必须说明
creator String 聊天室属主的账号accid
name String 聊天室名称,长度限制128个字符
announcement String公告,长度限制4096个字符
broadcasturl String 直播地址,长度限制1024个字符
ext String 扩展字段,最长4096字符

curl请求示例

curl -X POST -H "CheckSum: fc040248923c881f2fe7cc39602b79565230155c" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217360" -H "Content-Type: application/x-www-form-urlencoded" -d 'name=mychatroom&announcement=&broadcasturl=xxxxxx&creator=zhangsan' 'https://api.netease.im/nimserver/chatroom/create.action'

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "chatroom": {
    "roomid": 66,
    "valid": true,
    "announcement": null,
    "name": "mychatroom",
    "broadcasturl": "xxxxxx",
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

主要的返回码

200、403、414、416、419、431、500

具体请参考code状态表


查询聊天室信息

请求说明

POST https://api.netease.im/nimserver/chatroom/get.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

查询聊天室信息

参数说明

参数类型必须说明
roomid long 聊天室id
needOnlineUserCount String 是否需要返回在线人数,true或false,默认false

curl请求示例

curl -X POST -H "CheckSum: fc040248923c881f2fe7cc39602b79565230155c" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217360"  -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&needOnlineUserCount=true' 'https://api.netease.im/nimserver/chatroom/get.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "chatroom": {
    "roomid": 66,
    "valid": true,
    "muted":false, //聊天室是否处于全体禁言状态,全体禁言时仅管理员和创建者可以发言 
    "announcement": null,
    "name": "mychatroom",
    "broadcasturl": "xxxxxx",
    "onlineusercount": 1,
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

主要的返回码

200、403、404、414、416、431、500

具体请参考code状态表


更新聊天室信息

请求说明

POST https://api.netease.im/nimserver/chatroom/update.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

更新聊天室信息

参数说明

参数类型必须说明
roomid long 聊天室id
name String 聊天室名称,长度限制128个字符
announcement String 公告,长度限制4096个字符
broadcasturl String 直播地址,长度限制1024个字符
ext String 扩展字段,长度限制4096个字符
needNotify String true或false,是否需要发送更新通知事件,默认true
notifyExt String 通知事件扩展字段,长度限制2048

curl请求示例

curl -X POST -H "CheckSum: 95a26060d002a473057a71cb7d949d6e91d6d167" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451214690" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&name=mynewchatroom&announcement=mynewchatroom' 'https://api.netease.im/nimserver/chatroom/update.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "chatroom": {
    "roomid": 66,
    "valid": true,
    "announcement": "这是聊天室",
    "name": "mychatroom",
    "broadcasturl": "xxxxxx",
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

主要的返回码

200、403、404、414、416、431、500、13002

具体请参考code状态表


修改聊天室开/关闭状态

请求说明

POST https://api.netease.im/nimserver/chatroom/toggleCloseStat.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

修改聊天室开/关闭状态

参数说明

参数类型必须说明
roomid long 聊天室id
operator String 操作者账号,必须是创建者才可以操作
valid String true或false,false:关闭聊天室;true:打开聊天室

curl请求示例

curl -X POST -H "CheckSum: 95a26060d002a473057a71cb7d949d6e91d6d167" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451214690"  -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&operator=zhangsan&valid=true' 'https://api.netease.im/nimserver/chatroom/toggleCloseStat.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "roomid": 13,
    "valid": true,
    "announcement": "这是聊天室",
    "name": "myChatroom",
    "broadcasturl": "http://www.xxxx.com/xxxxxx",
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

主要的返回码

200、403、404、414、416、417、419、431、500

具体请参考code状态表


设置聊天室内用户角色

请求说明

POST https://api.netease.im/nimserver/chatroom/setMemberRole.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

设置聊天室内用户角色

参数说明

参数类型必须说明
roomid long 聊天室id
operator String 操作者账号accid
target String 被操作者账号accid
opt int 操作:
1: 设置为管理员,operator必须是创建者
2:设置普通等级用户,operator必须是创建者或管理员
-1:设为黑名单用户,operator必须是创建者或管理员
-2:设为禁言用户,operator必须是创建者或管理员
optvalue String true或false,true:设置;false:取消设置
notifyExt String 通知扩展字段,长度限制2048,请使用json格式

curl请求示例

curl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&operator=zhangsan&target=lisi&opt=2&optvalue=true' 'https://api.netease.im/nimserver/chatroom/setMemberRole.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "roomid": 16,
    "level": 10,
    "accid": "zhangsan",
    "type": "COMMON"
  },
  "code": 200
}

备注:
返回的type字段可能为:
        LIMITED,          //受限用户,黑名单+禁言 
        COMMON,           //普通固定成员
        CREATOR,          //创建者 
        MANAGER,          //管理员 
        TEMPORARY,        //临时用户,非固定成员

主要的返回码

200、403、404、414、416、417、419、431、500、13002

具体请参考code状态表


请求聊天室地址

请求说明

POST https://api.netease.im/nimserver/chatroom/requestAddr.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

请求聊天室地址与令牌

参数说明

参数类型必须说明
roomid long 聊天室id
accid String 进入聊天室的账号
clienttype int 1:weblink; 2:commonlink, 默认1

curl请求示例

curl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&accidzhangsan&clienttype=1' 'https://api.netease.im/nimserver/chatroom/requestAddr.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "addr": [
    "testchat.netease.im:6666",
    "testchat.netease.im:8888"
  ],
  "code": 200
}

主要的返回码

200、403、414、416、431、500、514、13002

具体请参考code状态表


发送聊天室消息

请求说明

POST https://api.netease.im/nimserver/chatroom/sendMsg.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

往聊天室内发消息

参数说明

参数类型必须说明
roomid long 聊天室id
msgId String 客户端消息id,使用uuid等随机串,msgId相同的消息会被客户端去重
fromAccid String 消息发出者的账号accid
msgType int 消息类型:
0: 表示文本消息,
1: 表示图片,
2: 表示语音,
3: 表示视频,
4: 表示地理位置信息,
6: 表示文件,
10: 表示Tips消息,
100: 自定义消息类型
resendFlag int 重发消息标记,0:非重发消息,1:重发消息,如重发消息会按照msgid检查去重逻辑
attach String 消息内容,格式同消息格式示例中的body字段,长度限制4096字符
ext String 消息扩展字段,内容可自定义,请使用JSON格式,长度限制4096字符
antispam String 本消息是否需要过自定义反垃圾系统。true或false, 默认false
antispamCustom String 自定义的反垃圾内容, 长度限制同attach字段,不能超过4096字符

curl请求示例

curl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&fromAccid=zhangsan&msgType=0&attach=This+is+test+msg&msgId=c9e6c306-804f-4ec3-b8f0-573778829419' 'https://api.netease.im/nimserver/chatroom/sendMsg.action'

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "desc":{
    "time": "1456396333115", 
    "fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV84NDU4OF8xNDU1ODczMjA2NzUwX2QzNjkxMjI2LWY2NmQtNDQ3Ni0E2LTg4NGE4MDNmOGIwMQ==",
    "msgid_client": "c9e6c306-804f-4ec3-b8f0-573778829419",
    "fromClientType": "REST",
    "attach": "This+is+test+msg",
    "roomId": "36",
    "fromAccount": "zhangsan",
    "fromNick": "张三",
    "type": "0",
    "ext": ""
  } 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


往聊天室内添加机器人

请求说明

POST https://api.netease.im/nimserver/chatroom/addRobot.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

往聊天室内添加机器人

参数说明

参数类型必须说明
roomid long 聊天室id
accids JSONArray 机器人账号accid列表,必须是有效账号,账号数量上限100个
roleExt String 机器人信息扩展字段,请使用json格式,长度4096字符
notifyExt String 机器人进入聊天室通知的扩展字段,请使用json格式,长度2048字符

curl请求示例

curl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&accids=["zhangsan","lisi"]' 'https://api.netease.im/nimserver/chatroom/addRobot.action'

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "failAccids": "[\"hzzhangsan\"]",
    "successAccids": "[\"hzlisi\"]"
  },
  "code": 200
}

主要的返回码

200、403、414、416、417、419、431、500、13003

具体请参考code状态表


从聊天室内删除机器人

请求说明

POST https://api.netease.im/nimserver/chatroom/removeRobot.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

从聊天室内删除机器人

参数说明

参数类型必须说明
roomid long 聊天室id
accids JSONArray 机器人账号accid列表,必须是有效账号,账号数量上限100个

curl请求示例

curl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&accids=["zhangsan","lisi"]' 'https://api.netease.im/nimserver/chatroom/removeRobot.action'

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "failAccids": "[\"hzzhangsan\"]",
    "successAccids": "[\"hzlisi\"]"
  },
  "code": 200
}

主要的返回码

200、403、404、414、416、419、431、500

具体请参考code状态表


设置临时禁言状态

请求说明

POST https://api.netease.im/nimserver/chatroom/temporaryMute.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

将聊天室内成员设置为临时禁言

参数说明

参数类型必须说明
roomid long 聊天室id
operator String 操作者accid,必须是管理员或创建者
target String 被禁言的目标账号accid
muteDuration long 0:解除禁言;>0设置禁言的秒数,不能超过2592000秒(30天)
needNotify String 操作完成后是否需要发广播,true或false,默认true
notifyExt String 通知广播事件中的扩展字段,长度限制2048字符

curl请求示例

curl -X POST -H "CheckSum: 66dc1ad0166a37037abcdfeb749bhh049c937777" -H "AppKey: acd7y640c85j8kf734219e1847aggggg" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=123&operator=zhangsan&target=lisi&muteDuration=300&notifyExt=这是扩展字段' "https://api.netease.im/nimserver/chatroom/temporaryMute.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "muteDuration": 300
  },
  "code": 200
}

主要的返回码

200、403、404、414、416、417、419、431、500、13002

具体请参考code状态表


往聊天室有序队列中新加或更新元素

请求说明

POST https://api.netease.im/nimserver/chatroom/queueOffer.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

往聊天室有序队列中新加或更新元素

参数说明

参数类型必须说明
roomid long 聊天室id
key String elementKey,新元素的UniqKey,长度限制128字符
value String elementValue,新元素内容,长度限制4096字符

curl请求示例

curl -X POST -H "CheckSum: 35dc67d0890f67007abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=1111&value=66666'  "https://api.netease.im/nimserver/chatroom/queueOffer.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


从队列中取出元素

请求说明

POST https://api.netease.im/nimserver/chatroom/queuePoll.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

从队列中取出元素

参数说明

参数类型必须说明
roomid long 聊天室id
key String 目前元素的elementKey,长度限制128字符,不填表示取出头上的第一个

curl请求示例

curl -X POST -H "CheckSum: 37dc19d0190007037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=333334444'   "https://api.netease.im/nimserver/chatroom/queuePoll.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": { 
    "value": "66666", 
    "key": "1111" 
  },
  "code": 200
}

主要的返回码

200、403、404、414、416、431、500

具体请参考code状态表


排序列出队列中所有元素

请求说明

POST https://api.netease.im/nimserver/chatroom/queueList.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

排序列出队列中所有元素

参数说明

参数类型必须说明
roomid long 聊天室id

curl请求示例

curl -X POST -H "CheckSum: 37dc87di0190037037900999b74kkbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=1111'    "https://api.netease.im/nimserver/chatroom/queueList.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": { 
    "list": [ 
      { 
        "33333": "33333" 
      } 
    ] 
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


删除清理整个队列

请求说明

POST https://api.netease.im/nimserver/chatroom/queueDrop.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

删除清理整个队列

参数说明

参数类型必须说明
roomid long 聊天室id

curl请求示例

curl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=k2&value=v2'  "https://api.netease.im/nimserver/chatroom/queueDrop.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": { 
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


初始化队列

请求说明

POST https://api.netease.im/nimserver/chatroom/queueInit.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

初始化队列

参数说明

参数类型必须说明
roomid long 聊天室id
sizeLimit long 队列长度限制,0~1000

curl请求示例

curl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=38&sizeLimit=10'  "https://api.netease.im/nimserver/chatroom/queueInit.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": { 
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


将聊天室整体禁言

请求说明

POST https://api.netease.im/nimserver/chatroom/muteRoom.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

设置聊天室整体禁言状态(仅创建者和管理员能发言)

参数说明

参数类型必须说明
roomid long 聊天室id
operator  String 操作者accid,必须是管理员或创建者
mute  String true或false
needNotify  String true或false,默认true
notifyExt  String 通知扩展字段

curl请求示例

curl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=4235&operator=zhangsan&mute=true'  "https://api.netease.im/nimserver/chatroom/muteRoom.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "success": true
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


查询聊天室统计指标TopN

请求说明

POST https://api.netease.im/nimserver/stats/chatroom/topn.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

1、根据时间戳,按指定周期列出聊天室相关指标的TopN列表
2、当天的统计指标需要到第二天才能查询

参数说明

参数类型必须说明
topn  int topn值,可选值 1~500,默认值100
timestamp long 需要查询的指标所在的时间坐标点,不提供则默认当前时间,单位秒/毫秒皆可
period  String 统计周期,可选值包括 hour/day, 默认hour
orderby  String 取排序值,可选值 active/enter/message,分别表示按日活排序,进入人次排序和消息数排序, 默认active

curl请求示例

curl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'timestamp=1471781873&period=hour&topn=3&orderby=enter'  "https://api.netease.im/nimserver/stats/chatroom/topn.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "code": 200,
  "data": [
    {
      "activeNums": 5955,       // 该聊天室内的活跃数
      "datetime": 1471712400,   // 统计时间点,单位秒,按天统计的是当天的0点整点;按小时统计的是指定小时的整点
      "enterNums": 18621,       // 进入人次数量
      "msgs": 2793,             // 聊天室内发生的消息数
      "period": "HOUR",         // 统计周期,HOUR表示按小时统计;DAY表示按天统计
      "roomId": 3571337         // 聊天室ID号
    },
    {
      "activeNums": 6047,
      "datetime": 1471708800,
      "enterNums": 15785,
      "msgs": 2706,
      "period": "HOUR",
      "roomId": 3573737
    },
    {
      "activeNums": 5498,
      "datetime": 1471708800,
      "enterNums": 14590,
      "msgs": 2258,
      "period": "HOUR",
      "roomId": 3513774
    }
  ]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


分页获取成员列表

请求说明

POST https://api.netease.im/nimserver/chatroom/membersByPage.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

分页获取成员列表

参数说明

参数类型必须说明
roomid  long 聊天室id
type int 需要查询的成员类型,0:固定成员;1:非固定成员;2:仅返回在线的固定成员
endtime  long 单位毫秒,按时间倒序最后一个成员的时间戳,0表示系统当前时间
limit  long 返回条数

curl请求示例

curl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=4235&type=0&endtime=0&limit=20'   "https://api.netease.im/nimserver/chatroom/membersByPage.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "data": [
      {
        "roomid": 111,
        "accid": "abc",
        "nick": "cba",
        "type": 1,
        "onlineStat": true
      }
    ]
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


批量获取在线成员信息

请求说明

POST https://api.netease.im/nimserver/chatroom/queryMembers.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

批量获取在线成员信息

参数说明

参数类型必须说明
roomid  long 聊天室id
accids JSONArray ["abc","def"], 账号列表,最多200条

curl请求示例

curl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=4235&accids=["abc","def"]' "https://api.netease.im/nimserver/chatroom/queryMembers.action"

返回说明

http 响应:json


"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "data": [
      {
        "roomid": 111,
        "accid": "abc",
        "nick": "cba",
        "type": 1,
        "onlineStat": true
      }
    ]
  },
  "code": 200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


历史记录

云端记录

接口描述

查询存储在云信服务器中的单人聊天历史消息,只能查询在保存时间范围内的消息

  1. 跟据时间段查询点对点消息,每次最多返回100条;
  2. 不提供分页支持,第三方需要跟据时间段来查询。

参数说明

参数类型必须说明
from String发送者accid
toString接收者accid
begintimeString开始时间,ms
endtime String截止时间,ms
limit int本次查询的消息条数上限(最多100条),小于等于0,或者大于100,会提示参数错误
reverse int1按时间正序排列,2按时间降序排列。其它返回参数414错误.默认是按降序排列

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'begintime=1443599631111&endtime=1443599639999&from=zhangsan&to=lisi&limit=50' 'https://api.netease.im/nimserver/history/querySessionMsg.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
   "code":200,
   "size":xxx,//总共消息条数
   "msgs":[各种类型的消息参见"历史消息查询返回的消息格式说明",JSONArray]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


接口描述

查询存储在云信服务器中的群聊天历史消息,只能查询在保存时间范围内的消息

  1. 跟据时间段查询群消息,每次最多返回100条;
  2. 不提供分页支持,第三方需要跟据时间段来查询。

参数说明

参数类型必须说明
tid String群id
accidString查询用户对应的accid.
begintimeString开始时间,ms
endtime String截止时间,ms
limit int本次查询的消息条数上限(最多100条),小于等于0,或者大于100,会提示参数错误
reverse int1按时间正序排列,2按时间降序排列。其它返回参数414错误。默认是按降序排列

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'begintime=1443599631111&endtime=1443599639999&tid=1513535&accid=zhangsan&limit=50' 'https://api.netease.im/nimserver/history/queryTeamMsg.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "size":xxx,//总共消息条数
  "msgs":[各种类型的消息参见"历史消息查询返回的消息格式说明",JSONArray]
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表

历史消息查询返回的消息格式说明
1.普通文本消息

{
    "from":”test1”,
    "msgid":792478,
    "sendtime":1430967883307,
    "type":0,//文本消息类型
    "body":{
        "msg":"哈哈哈"//消息内容
     }
}

2.图片消息

{
    "from":”test1”,
    "msgid":792502,
    "sendtime":1430978396680,   //发送时间ms
    "type":1    //图片类型消息
    "body":{
        "name":"图片发送于2015-05-07 13:59",         //图片name
        "md5":"9894907e4ad9de4678091277509361f7",   //md5
        "url":"http://nimtest.nos.netease.com/cbc500e8-e19c-4b0f-834b-c32d4dc1075e",    //生成的url
        "ext":"jpg",        //图片后缀
        "w":6814,       //宽
        "h":2332,       //高
        "size":388245       //图片大小
    }
}

3.语音消息

{
    "from":”test1”,
    "msgid":792479,
    "sendtime":1430967899646,   //发送时间ms
    "type":2    //语音类型消息
    "body":{
        "dur":4551,     //语音持续时长ms
        "md5":"87b94a090dec5c58f242b7132a530a01",   //md5
        "url":"http://nimtest.nos.netease.com/a2583322-413d-4653-9a70-9cabdfc7f5f9",    //生成的url
        "ext":"aac",        //语音消息格式,只能是aac格式
        "size":16420        //语音文件大小
    }
}

4.视频消息

{
    "from":”test1”,
    "msgid":792505,
    "sendtime":1430978424249,   //发送时间ms
    "type":3    //视频类型消息
    "body":{
        "dur":8003,     //视频持续时长ms
        "md5":"da2cef3e5663ee9c3547ef5d127f7e3e",   //md5
        "url":"http://nimtest.nos.netease.com/21f34447-e9ac-4871-91ad-d9f03af20412",    //生成的url
        "w":360,    //宽
        "h":480,    //高
        "ext":"mp4",    //视频格式
        "size":16420    //视频文件大小
    }
}

5.地理位置消息

{
    "from":”test1”,
    "msgid":792501,
    "sendtime":1430978381896,   //发送时间ms
    "type":4    //地理位置类型消息
    "body":{
        "title":"中国 浙江省 杭州市 网商路 599号",  //地理位置title
        "lng":120.1908686708565,        // 经度
        "lat":30.18704515647036         // 纬度
    }
}

6.文件消息

{
    "msgid":7925061,
    "sendtime":1430978435894,   //发送时间ms
    "type":6    //文件消息
    "body":{
       "name":"BlizzardReg.ttf",   //文件名
       "md5":"79d62a35fa3d34c367b20c66afc2a500", //文件MD5
       "url":"http://nimtest.nos.netease.com/08c9859d-183f-4daa-9904-d6cacb51c95b", //文件URL
       "ext":"ttf",    //文件后缀类型
       "size":91680    //大小
    }
}

7.第三方自定义消息

{
    "msgid":792506,
    "sendtime":1430978435894,   //发送时间ms
    "type":100, //第三方自定义消息
    "body":{     //自定义的内容,需要符合json格式
        …
    }
}

8.群内系统通知

{
    "msgid ":278703112201,
    "from":"t4",                //通知发起者
    "sendtime":1430978435894,   //发送时间ms
    "type":5    //群notifycation通知
    "body":{
       "tid":4153,     //群id
       "tname":"key1", //群名称 (某些操作会有)
       "ope":1,            //notify通知类型 (0:群拉人,1:群踢人,2:退出群,3:群信息更新,4:群解散,5:申请加入群成功,6:退出并移交群主,7:增加管理员,8:删除管理员,9:接受邀请进群)
       "accids":["t2"],    //被操作的对象 (群成员操作时才有)
       "intro":"群介绍",  //(ope=3时群信息修改项)
       "announcement":"群公告", (ope=3时群信息修改项)
       "joinmode":1,       //加入群的模式0不需要认证,1需要认证 ,(ope=3时群信息修改项)
       "config":"第三方服务器配制修改项",(ope=3时群信息修改项)
       "updatetime":1432804852021 //通知后台更新时间 (群操作时有)
    }
}

接口描述

1.跟据时间段查询用户的登录登出记录,每次最多返回100条。
2.不提供分页支持,第三方需要跟据时间段来查询。

参数说明

参数类型必须说明
accid String要查询用户的accid
begintimeString开始时间,ms
endtime String截止时间,ms
limit int本次查询的消息条数上限(最多100条),小于等于0,或者大于100,会提示参数错误
reverse int1按时间正序排列,2按时间降序排列。其它返回参数414错误。默认是按降序排列

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'tid=11111&begintime=1448948957018&endtime=1448955895518&limit=50' 'https://api.netease.im/nimserver/history/queryUserEvents.action'

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{ 
  "code":200, 
  "size":xxx,//总共记录数 
  "events": 
  [ 
    { 
      "accid":"t4",    //用户accid 
      "timestamp":1452058433412, //发生时间,ms 
      "eventType":2,    //2表示登录,3表示登出 
      "clientIp":"8.8.8.8", //用户clientip 
      "sdkVersion":12, //sdk 版本 
      "clientType":"IOS", //终端 
      "code":200    //登录成功状态,200表示成功 
    }, 
    { 
      "accid":"t4",    //用户accid 
      "timestamp":1452058381580,    //发生时间,ms 
      "eventType":3,    //2表示登录,3表示登出 
      "clientIp":"8.8.8.8", //用户clientip 
      "sdkVersion":12, //sdk 版本 
      "clientType":"IOS", //终端 
      "code":200    //登录成功状态,200表示成功 
    } 
  ] 
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


接口描述

1.此接口有频控限制,每分钟可调用不超过300次

参数说明

参数类型必须说明
channelid long需要删除的文件的通道号

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 12345" -H "CurTime: 1459154905" -H "CheckSum: 8d3ef001b160bda737c779d75d906e48e75fc9d3" -H "Content-Type: application/x-www-form-urlencoded" -d 'channelid=6155666599001755899' "https://api.netease.im/nimserver/history/deleteMediaFile.action"

返回说明

http 响应:json

"Content-Type": "application/json; charset=utf-8"
{ 
  "code":200
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


短信服务

参考短信接口指南


专线电话

参考专线电话接口指南


消息抄送

消息抄送功能概述

会话类型消息抄送

假设第三方开发者的消息接收地址为:

http://yunxinservice.com.cn/receiveMsg.action,
以下的第三方接口均假设为此接口,不再赘述。
1. "eventType"="1"
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"attach":"thisisattach","body":"hello","convType":"PERSON","eventType":"1","fromAccount":"111","fromClientType":"IOS","fromDeviceId":"thisisfromdeviceid","fromNick":"mike","msgTimestamp":"1441977355557","msgType":"TEXT","msgidClient":"1234567","msgidServer":"3456789","resendFlag":"0","to":"222"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"attach":"thisisattach","body":"hello","convType":"PERSON","eventType":"1","fromAccount":"111","fromClientType":"IOS","fromDeviceId":"thisisfromdeviceid","fromNick":"mike","msgTimestamp":"1441977355557","msgType":"TEXT","msgidClient":"1234567","msgidServer":"3456789","resendFlag":"0","to":"222"}' 'http://yunxinservice.com.cn/receiveMsg.action'
会话类型消息中,并不是每个字段都会一定抄送,请注意对各字段的判空处理。
以下为一般情况下必有的字段:
eventType、convType、tofromAccount、msgTimestamp、msgType、msgidClient、msgidServer
名称类型说明
eventType String值为1,表示是会话类型的消息
convType String会话具体类型:
PERSON(二人会话数据)、TEAM(群聊数据)、
CUSTOM_PERSON(个人自定义系统通知)、CUSTOM_TEAM(群组自定义系统通知),字符串类型
to String若convType为PERSON或CUSTOM_PERSON,则to为消息接收者的用户账号,字符串类型;
若convType为TEAM或CUSTOM_TEAM,则to为tid,即群id,可转为Long型数据
fromAccount String消息发送者的用户账号,字符串类型
fromClientType String发送客户端类型: AOS、IOS、PC、WINPHONE、WEB、REST,字符串类型
fromDeviceId String发送设备id,字符串类型
fromNick String发送方昵称,字符串类型
msgTimestamp String消息发送时间,字符串类型
msgType String 会话具体类型PERSON、TEAM对应的通知消息类型:
TEXT、
PICTURE、
AUDIO、
VIDEO、
LOCATION 、
NOTIFICATION、
FILE、 //文件消息
NETCALL_AUDIO、 //网络电话音频聊天
NETCALL_VEDIO、 //网络电话视频聊天
DATATUNNEL_NEW、 //新的数据通道请求通知
TIPS、 //提醒类型消息
CUSTOM //自定义消息

会话具体类型CUSTOM_PERSON对应的通知消息类型:
FRIEND_ADD、 //加好友
FRIEND_DELETE、 //删除好友
CUSTOM_P2P_MSG、 //个人自定义系统通知

会话具体类型CUSTOM_TEAM对应的通知消息类型:
TEAM_APPLY、 //申请入群
TEAM_APPLY_REJECT、 //拒绝入群申请
TEAM_INVITE、 //邀请进群
TEAM_INVITE_REJECT、 //拒绝邀请
TLIST_UPDATE、 //群信息更新
CUSTOM_TEAM_MSG、 //群组自定义系统通知
body String消息内容,字符串类型
attach String附加消息,字符串类型
msgidClient String客户端生成的消息id,仅在convType为PERSON或TEAM含此字段,字符串类型
msgidServer String服务端生成的消息id,可转为Long型数据
resendFlag String重发标记:0不是重发, 1是重发。仅在convType为PERSON或TEAM时含此字段,可转为Integer类型数据
customSafeFlag String自定义系统通知消息是否存离线:0:不存,1:存。
仅在convType为CUSTOM_PERSON或CUSTOM_TEAM时含此字段,可转为Integer类型数据
customApnsText String自定义系统通知消息推送文本。仅在convType为CUSTOM_PERSON或CUSTOM_TEAM时含此字段,字符串类型
tMembers String 跟本次群操作有关的用户accid,仅在convType为TEAM或CUSTOM_TEAM时含此字段,字符串类型。
tMembers格式举例:
{
... // 其他字段
"tMembers":"[123, 456]" //相关的accid为 123 和 456
}
ext String消息扩展字段
antispam String标识是否被反垃圾,仅在被反垃圾时才有此字段,可转为Boolean类型数据
讨论组和高级群相关消息抄送中部分字段的格式定义如下:
———————————————————————————————————————————————————————————————
attach字段中tinfo字段的定义,为JSONObject:
    //群信息
    "tinfo": {
        "1":"群组id,可转为Long型",
        "3":"群名称",
        "4":"群类型,0表示讨论组,1表示高级群",
        "5":"创建者用户帐号",
        "7":"群公告等各种属性",
        "8":"群有效标记,0表示无效,1表示有效",
        "9":"群有效成员个数",
        "10":"群组成员列表更新的时间戳,精确到毫秒",
        "11":"创建时间,精确到毫秒",
        "12":"更新时间,精确到毫秒",
        "14":"群介绍",
        "15":"群公告,为JSONArray的toString,格式参考下文",
        "16":"群属性,0表示入群不需要申请,1表示入群需要申请",
        "18":"第三方扩展字段",
        "19":"第三方服务器扩展字段",
        "20":"群头像",
        "21":"被邀请人同意方式", 0:需要统一(默认),1:不需要同意,
        "22":"谁可以邀请他人入群", 0:管理员(默认),1:所有人,
        "23":"谁可以修改群资料", 0:管理员(默认),1:所有人,
        "24":"谁可以更新群自定义属性"0:管理员(默认),1:所有人
    }

tinfo中"15"群公告字段的格式如下:
    "tinfo": {
        "15": "
         [
            {
                "title":"这是群公告标题",
                "content":"这是群公告内容",
                "creator":"群公告发表者",
                "time":1457075964         //群公告发表时间,10位时间戳,精确到秒
            },
            {}
         ]
        ",
        //其他的字段
    }
———————————————————————————————————————————————————————————————
attach字段中uinfos字段的定义,为JSONArray:
    //用户信息
    "uinfos": [
        {
            "1":"用户帐号",
            "3":"用户昵称",
            "4":"用户头像地址",
            "5":"个性签名",
            "6":"性别",
            "7":"邮箱",
            "8":"生日",
            "9":"手机号",
            "10":"扩展字段",
            "12":"创建时间",
            "13":"更新时间"
        },
        {}
    ]
———————————————————————————————————————————————————————————————
attach字段中id字段的释义:
0:TEAM_INVITE,即群拉人
1:TEAM_KICK,即群踢人
2:TEAM_LEAVE,即退出群
3:TEAM_UPDATE,即更新群信息
4:TEAM_DISMISS,即群解散
5:TEAM_APPLY_PASS,即群申请加入成功
6:TEAM_OWNER_TRANSFER,即群主退群并移交群主
7:TEAM_ADD_MANAGER,即增加管理员
8:TEAM_REMOVE_MANAGER,即删除管理员
9:TEAM_INVITE_ACCEPT,即群接受邀请进群
———————————————————————————————————————————————————————————————
注意:没有给出定义的字段都是第三方无需关心的字段,可忽略

1.4.2.1、创建讨论组:

抄送示例:
{"attach":"{\"data\":{\"ids\":[\"wangwu\",\"zhaoliu\",\"lisi\"],\"tinfo\":{\"1\":\"11927\",\"10\":\"1458886362629\",\"11\":\"1458886362629\",\"12\":\"1458886362629\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"讨论组\",\"4\":\"0\",\"5\":\"zhangsan\",\"6\":\"10000\",\"8\":\"1\",\"9\":\"4\"},\"uinfos\":[{\"1\":\"wangwu\",\"11\":\"236911\",\"12\":\"1457417052774\",\"13\":\"1457491548992\",\"2\":\"11011\",\"3\":\"wangwu\",\"6\":\"0\"},{\"1\":\"zhaoliu\",\"11\":\"237017\",\"12\":\"1457492303776\",\"13\":\"1457492303776\",\"2\":\"11011\",\"3\":\"zhaoliu\",\"6\":\"0\"},{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1456885865056\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"1\"}]},\"id\":0}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1458886362746","msgType":"NOTIFICATION","msgidClient":"731f5145-0f98-4ae2-aaa4-ee0f210507d2","msgidServer":"800407420929","resendFlag":"0","tMembers":"[zhangsan]","to":"11927"}

attach字段释义
{
  "data": {
    //ids表示创建讨论组时被拉入讨论组的用户账号
    "ids":[
        "wangwu","zhaoliu","lisi"
    ],
    //群信息,具体参考tinfo字段的定义
    "tinfo": {

    },
    //创建讨论组时被拉入讨论组的用户,以及讨论组创建者的用户帐号信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 0    //讨论组拉人,创建讨论组时需拉人
}

tMembers字段释义:
{
    "tMembers":"[zhangsan]" //讨论组创建者
}

1.4.2.2、修改讨论组信息:

抄送示例:
{"attach":"{\"data\":{\"tinfo\":{\"1\":\"11927\",\"3\":\"修改后的讨论组名称\"},\"uinfos\":[{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1456885865056\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"1\"}]},\"id\":3}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1458886916106","msgType":"NOTIFICATION","msgidClient":"dd741c41-0a3a-4ef4-900b-ffbceffe3d22","msgidServer":"800407420931","resendFlag":"0","tMembers":"[zhaoliu, wangwu, zhangsan, lisi]","to":"11927"}

attach字段释义
{
  "data": {
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //创建讨论组时被拉入讨论组的用户,以及讨论组创建者的用户帐号信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 3    //修改讨论组信息
}

tMembers字段释义:
{
    "tMembers":"[zhaoliu, wangwu, zhangsan, lisi]" //讨论组内成员
}

1.4.2.3、讨论组拉人:

抄送示例:
{"attach":"{\"data\":{\"ids\":[\"lisi\"],\"tinfo\":{\"1\":\"11927\",\"10\":\"1458887669091\",\"11\":\"1458886362629\",\"12\":\"1458887669121\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"修改后的讨论组名称\",\"4\":\"0\",\"5\":\"zhangsan\",\"6\":\"10000\",\"8\":\"1\",\"9\":\"3\"},\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1456885865056\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"1\"}]},\"id\":0}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1458887669137","msgType":"NOTIFICATION","msgidClient":"e5fe2160-de34-4e1c-a87b-7f298aa7b7b2","msgidServer":"800407420940","resendFlag":"0","tMembers":"[zhaoliu, zhangsan]","to":"11927"}

attach字段释义
{
  "data": {
      //ids表示被加入的用户帐号
      "ids":[
          "lisi"
      ],
      //群组信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //被加入的用户,以及操作人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 0    //群拉人
}

tMembers字段释义:
{
    "tMembers":"[zhaoliu, zhangsan]" //讨论组内原有成员,不包含被拉人的用户
}

1.4.2.4、讨论组踢人:

抄送示例:
{"attach":"{\"data\":{\"ids\":[\"wangwu\"],\"tinfo\":{\"1\":\"11927\",\"10\":\"1458887253106\",\"11\":\"1458886362629\",\"12\":\"1458887253159\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"修改后的讨论组名称\",\"4\":\"0\",\"5\":\"zhangsan\",\"6\":\"10000\",\"8\":\"1\",\"9\":\"3\"},\"uinfos\":[{\"1\":\"wangwu\",\"11\":\"236911\",\"12\":\"1457417052774\",\"13\":\"1457491548992\",\"2\":\"11011\",\"3\":\"wangwu\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1456885865056\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"1\"}]},\"id\":1}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1458887253168","msgType":"NOTIFICATION","msgidClient":"693b8b53-3d0e-445e-b086-debaffa7a376","msgidServer":"800407420932","resendFlag":"0","tMembers":"[zhaoliu, wangwu, zhangsan, lisi]","to":"11927"}

attach字段释义
{
  "data": {
      //ids表示被踢出讨论组的用户帐号
      "ids":[
          "wangwu"
      ],
      //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //被踢的用户,以及操作人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 1    //讨论组踢人
}

tMembers字段释义:
{
    "tMembers":"[zhaoliu, wangwu, zhangsan, lisi]" //讨论组内成员,包含被踢出的用户
}

1.4.2.5、退出讨论组:

抄送示例:
{"attach":"{\"data\":{\"tinfo\":{\"1\":\"11927\",\"10\":\"1458887477194\",\"11\":\"1458886362629\",\"12\":\"1458887477199\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"修改后的讨论组名称\",\"4\":\"0\",\"5\":\"zhangsan\",\"6\":\"10000\",\"8\":\"1\",\"9\":\"2\"},\"uinfos\":[{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1456885865056\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"1\"}]},\"id\":2}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"","fromNick":"zhangsan","msgTimestamp":"1458887477210","msgType":"NOTIFICATION","msgidClient":"4bcad22a-12de-4691-9ba7-fa112aa46ea7","msgidServer":"800407420936","resendFlag":"0","tMembers":"[wangwu, zhaoliu, zhangsan, lisi]","to":"11927"}

attach字段释义
{
  "data": {
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //退出讨论组的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {}
    ]
  },
  "id": 2    //退出讨论组
}

tMembers字段释义:
{
    "tMembers":"[zhaoliu, wangwu, zhangsan, lisi]" //讨论组内成员,包含退出的用户
}

1.4.3.1、创建高级群:

抄送示例:
{"attach":"{\"tinfo\":{\"1\":\"11620\",\"10\":\"1456802852027\",\"11\":\"1456802852027\",\"12\":\"1456802852027\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"1\"}}","body":"邀请你加入群组","convType":"CUSTOM_TEAM","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456802852094","msgType":"TEAM_INVITE","msgidServer":"371929","tMembers":"[lisi]","to":"11620"}

attach字段释义
{
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    }
}

1.4.3.2、解散高级群

抄送示例:
{"attach":"{\"data\":{\"uinfos\":[{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"}]},\"id\":4}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromNick":"zhangsan","msgTimestamp":"1456810468999","msgType":"NOTIFICATION","msgidClient":"b697a6b2-be71-47f0-8fc0-3c7ff9b15dda","msgidServer":"779872108546","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11621"}

attach字段释义
{
  "data": {
    //解散群的操作人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 4    //解散群
}

tMembers字段释义:
{
    "tMembers":"[lisi]" //解散高级群时的群内所有成员列表,包含群主
}

1.4.3.3、高级群邀请他人加群

抄送示例:
{"attach":"{\"tinfo\":{\"1\":\"11623\",\"10\":\"1456817802112\",\"11\":\"1456811497999\",\"12\":\"1456817802112\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"1\"}}","body":"邀请你加入群组","convType":"CUSTOM_TEAM","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456818444874","msgType":"TEAM_INVITE","msgidServer":"373171","tMembers":"[lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    }
  }
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //被邀请入群的用户列表
}

1.4.3.4、高级群接受邀请入群

抄送示例:
{"attach":"{\"data\":{\"id\":\"zhangsan\",\"tinfo\":{\"1\":\"11623\",\"10\":\"1456811521765\",\"11\":\"1456811497999\",\"12\":\"1456811521899\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"2\"},\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"}]},\"id\":9}","convType":"TEAM","eventType":"1","fromAccount":"lisi","fromClientType":"IOS","msgTimestamp":"1456811521946","msgType":"NOTIFICATION","msgidClient":"335cf3bb-8efa-4cde-953d-9aa775f1a2b2","msgidServer":"780006326273","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //邀请人
    "id":"邀请人的帐号",
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //邀请人与被邀请人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 9    //高级群接受邀请邀请入群
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括邀请人和被邀请人
}

1.4.3.5、高级群拒绝邀请入群

抄送示例:
{"body":"","convType":"CUSTOM_TEAM","customSafeFlag":"0","eventType":"1","fromAccount":"lisi","msgTimestamp":"1456819928681","msgType":"TEAM_INVITE_REJECT","msgidServer":"373998","to":"11623"}

1.4.3.6、高级群增加管理员

抄送示例:
{"attach":"{\"data\":{\"ids\":[\"lisi\"],\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"}]},\"id\":7}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1456813138663","msgType":"NOTIFICATION","msgidClient":"3e3e2efe-4f16-4ac2-8669-a8ee17be80bc","msgidServer":"780006326274","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //邀请人
    "ids":[
        "被设为管理员的用户帐号1",
        "被设为管理员的用户帐号2"
    ],
    //操作人与被操作人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 7    //高级群增加管理员
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括操作人和被操作人
}

1.4.3.7、高级群删除管理员

抄送示例:
{"attach":"{\"data\":{\"ids\":[\"lisi\"],\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"}]},\"id\":8}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1456815660948","msgType":"NOTIFICATION","msgidClient":"a2b8f49a-cc06-4784-a8e4-84b59c9ac85f","msgidServer":"780006326275","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //邀请人
    "ids":[
        "被删除管理员的用户帐号1",
        "被删除管理员的用户帐号2"
    ],
    //操作人与被操作人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 8    //高级群删除管理员
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括操作人和被操作人
}

1.4.3.8、高级群踢人出群

抄送示例:
{"attach":"{\"data\":{\"ids\":[\"lisi\"],\"tinfo\":{\"1\":\"11623\",\"10\":\"1456816081224\",\"11\":\"1456811497999\",\"12\":\"1456816081359\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"1\"},\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"}]},\"id\":1}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1456816081368","msgType":"NOTIFICATION","msgidClient":"f3c0437d-fd3c-4900-9b80-ef9c86c1f91f","msgidServer":"780006326276","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //邀请人
    "ids":[
        "被踢出群的用户帐号1",
        "被踢出群的用户帐号2"
    ],
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //操作人与被操作人的用户信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 1    //高级群踢人出群
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括操作人和被操作人
}

1.4.3.9、高级群申请加入成功(无需加群验证)

抄送示例:
{"attach":"{\"data\":{\"id\":\"lisi\",\"tinfo\":{\"1\":\"11631\",\"10\":\"1457075685304\",\"11\":\"1456823028193\",\"12\":\"1457075963090\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"2\"},\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"},{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"}]},\"id\":5}","convType":"TEAM","eventType":"1","fromAccount":"lisi","fromClientType":"IOS","msgTimestamp":"1457076245920","msgType":"NOTIFICATION","msgidClient":"39a89280-edda-47ff-8f2a-3a2a9ae03cf4","msgidServer":"780543197222","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11631"}

attach字段释义:
{
  "data": {
    //邀请人
    "id":"申请加入成功的用户帐号",
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //操作人与被操作人的用户信息,
    //此处操作人与被操作人是同一个人,uinfos包含两条同样的信息
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 5    //高级群申请加入成功
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括加入成功的用户
}

1.4.3.10、申请加入高级群(需要验证)

抄送示例:
{"body":"wangwu申请加群","convType":"CUSTOM_TEAM","customSafeFlag":"0","eventType":"1","fromAccount":"lisi","msgTimestamp":"1456821259709","msgType":"TEAM_APPLY","msgidServer":"375024","tMembers":"[zhangsan, li]","to":"11623"}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群主和管理员帐号
}

1.4.3.11、允许加群申请

抄送示例:
{"attach":"{\"data\":{\"id\":\"lisi\",\"tinfo\":{\"1\":\"11623\",\"10\":\"1456821386734\",\"11\":\"1456811497999\",\"12\":\"1456821386758\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"1\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"2\"},\"uinfos\":[{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"},{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"}]},\"id\":5}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1456821386769","msgType":"NOTIFICATION","msgidClient":"dd36c8a2-30e7-476a-9608-48879f4d3146","msgidServer":"780006326282","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //邀请人
    "id":"申请加群的用户帐号",
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //操作人与被操作人的用户信息,
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 5    //高级群申请加入成功
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括加入成功的用户
}

1.4.3.12、拒绝加群申请

抄送示例:
{"attach":"{\"tinfo\":{\"1\":\"11623\",\"10\":\"1456821961295\",\"11\":\"1456811497999\",\"12\":\"1456821961295\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"1\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"1\"}}","body":"","convType":"CUSTOM_TEAM","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456822044104","msgType":"TEAM_APPLY_REJECT","msgidServer":"375093","to":"11623"}

attach字段释义:
{
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    }
}

1.4.3.13、退出高级群

抄送示例:
{"attach":"{\"data\":{\"tinfo\":{\"1\":\"11623\",\"10\":\"1456817802112\",\"11\":\"1456811497999\",\"12\":\"1456817802112\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"zhangsan\",\"6\":\"10\",\"8\":\"1\",\"9\":\"1\"},\"uinfos\":[{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"}]},\"id\":2}","convType":"TEAM","eventType":"1","fromAccount":"lisi","fromClientType":"IOS","fromNick":"lisi","msgTimestamp":"1456817802118","msgType":"NOTIFICATION","msgidClient":"9ea8ad94-7b8e-4793-8302-23b554b3d5ca","msgidServer":"780006326278","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}

attach字段释义:
{
  "data": {
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //退出群的用户信息,
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 2    //退出高级群
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括退出群的用户
}

1.4.3.14、更新高级群

抄送示例:
{"attach":"{\"data\":{\"tinfo\":{\"1\":\"11623\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"1\"},\"uinfos\":[{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"}]},\"id\":3}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","msgTimestamp":"1456822570528","msgType":"NOTIFICATION","msgidClient":"473b64e3-5b76-4fd8-ba74-b29a8ec71f7d","msgidServer":"780006326286","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11623"}


attach字段释义:
{
  "data": {
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //更新群信息的操作人信息,
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 3    //更新群信息
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括更新群的用户
}

1.4.3.15、移交群主

抄送示例:
{"attach":"{\"data\":{\"id\":\"lisi\",\"tinfo\":{\"1\":\"11631\",\"10\":\"1456823264040\",\"11\":\"1456823028193\",\"12\":\"1456823264170\",\"14\":\"这是群介绍\",\"15\":\"[{\\\"title\\\":\\\"这是群公告标题\\\",\\\"content\\\":\\\"这是群公告内容\\\",\\\"creator\\\":\\\"zhangsan\\\",\\\"time\\\":1457075964}]\",\"16\":\"0\",\"17\":\"0\",\"2\":\"11011\",\"21\":\"0\",\"22\":\"0\",\"23\":\"0\",\"24\":\"0\",\"3\":\"高级群\",\"4\":\"1\",\"5\":\"lisi\",\"6\":\"10\",\"8\":\"1\",\"9\":\"2\"},\"uinfos\":[{\"1\":\"zhangsan\",\"11\":\"142915\",\"12\":\"1438738423546\",\"13\":\"1446624332920\",\"2\":\"11011\",\"3\":\"zhangsan\",\"4\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=\",\"6\":\"0\"},{\"1\":\"lisi\",\"11\":\"142916\",\"12\":\"1438740370586\",\"13\":\"1438740370586\",\"2\":\"11011\",\"3\":\"lisi\",\"6\":\"0\"}]},\"id\":6}","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"REST","msgTimestamp":"1456823264181","msgType":"NOTIFICATION","msgidClient":"92606e37-e22f-4cd1-a13c-fc6ec7353a1b","msgidServer":"780543197186","resendFlag":"0","tMembers":"[zhangsan, lisi]","to":"11631"}

attach字段释义:
{
  "data": {
    "id":"新群主的用户帐号"
    //群信息
    //具体参考tinfo字段的定义
    "tinfo": {

    },
    //新群主和老群主的信息,
    //具体参考uinfos字段的定义
    "uinfos": [
        {},
        {}
    ]
  },
  "id": 6    //更新群信息
}

tMembers字段释义:
{
    "tMembers":"[zhangsan, lisi]" //群内有效用户帐号列表,包括新群主和老群主
}
1.4.4.1、加好友
抄送示例:
{"attach":"{\"vt\":1}","body":"","convType":"CUSTOM_PERSON","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456827801260","msgType":"FRIEND_ADD","msgidServer":"375387","to":"lisi"}

attach字段释义:
{
  "vt": 1   //vt即verify type,加好友验证类型。1:直接加好友,无需验证;2:请求加好友,需要验证;3:同意加好友申请;4:拒绝加好友申请
}

1.4.4.2、删除好友

抄送示例:
{"convType":"CUSTOM_PERSON","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456827724200","msgType":"FRIEND_DELETE","msgidServer":"375386","to":"lisi"}

1.4.5.1、P2P:文本消息

抄送示例:
{"attach":"","body":"文字消息","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456888017105","msgType":"TEXT","msgidClient":"f33f0716-6027-47de-a582-37a8dc2d217c","msgidServer":"8364607","resendFlag":"0","to":"lisi"}

1.4.5.2、P2P:图片消息

抄送示例:
{"attach":"{\"md5\":\"d0323f8d447abf3df7256bd66f9d5b62\",\"h\":500,\"ext\":\"jpg\",\"size\":9093,\"w\":500,\"name\":\"图片发送于2016-03-02 11:09\",\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyOF8wOWE1ZmVlMS1lOGQ4LTQwMzItOGZkMS0yMWE1ODBjYjA1MWE=\"}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456888195062","msgType":"PICTURE","msgidClient":"472f2f50-2b00-4d7b-8b8d-d8870daa0dbd","msgidServer":"8364613","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "md5":"xxxxxxxx",      //图片的md5值
  "h":500,               //图片的高
  "w":500,               //图片的宽
  "size":9093,           //图片的大小
  "name":"xxxxxxxx",     //图片的名称
  "url":"xxxxxxxx",      //图片的url
  "ext":"jpg"            //图片格式
}

1.4.5.3、P2P:音频消息

抄送示例:
{"attach":"{\"size\":14181,\"ext\":\"aac\",\"dur\":3900,\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyN18xYjRlOTc4My0zYzFkLTQ5NzUtOTY2NC1hOTkzMzAzOGZiZjc=\",\"md5\":\"4c5cc81dd00817b548b5eef42eac4d11\"}","body":"发来了一段语音","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456888940830","msgType":"AUDIO","msgidClient":"b0b703ea-3e10-453e-8650-e3a2802130bd","msgidServer":"8364635","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "size":14181,          //音频的大小
  "ext":"aac",           //音频的格式
  "dur":3900,            //音频的时长
  "url":"xxxxxxxx",      //音频的url
  "md5":"xxxxxxxx"       //音频的md5值
}

1.4.5.4、P2P:视频消息

抄送示例:
{"attach":"{\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyN18xZGNkMjQzNi02OTg2LTQxNGEtYWE5ZC04ZDhmYjQyMTE2OTQ=\",\"md5\":\"c2f2e15af1c9e341187f81e5f8453399\",\"ext\":\"mp4\",\"h\":480,\"size\":114347,\"w\":360,\"name\":\"视频发送于2016-03-02 11:16\",\"dur\":1456}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456888595916","msgType":"VIDEO","msgidClient":"57a33622-cd80-4c65-b8d3-15f3c2bb128f","msgidServer":"8364616","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "url":"xxxxxxxx",      //视频的url
  "md5":"xxxxxxxx",      //视频的md5值
  "ext":"mp4",           //视频的格式
  "h":"480",             //视频的高
  "w":"360",             //视频的宽
  "size":14181,          //视频的大小
  "name":"xxxxxxxx",     //视频的名称
  "dur":1456             //视频的时长
}

1.4.5.5、P2P:地理位置信息

抄送示例:
{"attach":"{\"lat\":30.18704515647036,\"lng\":120.1908686708565,\"title\":\"中国 浙江省 杭州市 网商路 599号\"}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"REST","fromDeviceId":"","fromNick":"zhangsan","msgTimestamp":"1456897243862","msgType":"LOCATION","msgidClient":"6f9804ac-d584-422e-85a2-5f0167df65cf","msgidServer":"8364682","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "lat":30.18704515647036,   //纬度
  "lng":120.1908686708565,   //经度
  "title":"xxxxxxxx"         //地理位置的title
}

1.4.5.6、P2P:文件消息

抄送示例:
{"attach":"{\"ext\":\"ttf\",\"md5\":\"79d62a35fa3d34c367b20c66afc2a500\",\"name\":\"BlizzardReg.ttf\",\"size\":\"91680\",\"url\":\"http:\\/\\/nimtest.nos.netease.com\\/08c9859d-183f-4daa-9904-d6cacb51c95b\"}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"E8977274-3CD1-494D-95C4-EA633G63B5B5","fromNick":"zhangsan","msgTimestamp":"1456897960993","msgType":"FILE","msgidClient":"e1177d7c-c693-4a91-b0ef-f47f48793d9e","msgidServer":"8364686","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "ext":"xxxxxxxx",          //文件的类型
  "md5":"xxxxxxxx",          //文件的md5值
  "name":"xxxxxxxx",         //文件名
  "size":"xxxxxxxx",         //文件的大小
  "url":"xxxxxxxx"           //文件的URL
}

1.4.5.7、P2P:自定义消息(msgType类型为CUSTOM)

抄送示例:
{"attach":"{"myKey1":\"myValue1\",\"myKey2\":2}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"REST","fromDeviceId":"","fromNick":"zhangsan","msgTimestamp":"1456898248757","msgType":"CUSTOM","msgidClient":"1f929f45-1b5e-495e-b76c-465a4187be52","msgidServer":"8364702","resendFlag":"0","to":"lisi"}

attach字段释义:由第三方自己定义并解析相应的Key-Value值


SDK中定义的几类自定义消息释义: 
————————————————
剪刀石头布(type = 1):
{"attach":"{\"type\":1,\"data\":{\"value\":1}}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456904008340","msgType":"CUSTOM","msgidClient":"39efd6b1-a6f4-41cd-88f8-357cdf385d3e","msgidServer":"8365170","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "type":1                                    //type=1表示是剪刀石头布
  "data": {
    "value":1                                 //1:石头;2:剪刀;3:布
  }
}
————————————————
阅后即焚(type = 2):
{"attach":"{\"type\":2,\"data\":{\"md5\":\"8C40A5F0F56A8FA2CAC5D2A487D3D429\",\"fired\":false,\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl9iOTI4MmVhMC02ZTM2LTQ3YjYtOTVhNC01MWRmNmI3NjZjMzg=\"}}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456904040460","msgType":"CUSTOM","msgidClient":"f11be78c-31d9-48f3-92f8-35a3806c3511","msgidServer":"8365185","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "type":2                                    //type=2表示是阅后即焚
  "data": {
    "md5":8C40A5F0F56A8FA2CAC5D2A487D3D429,   //阅后即焚的图片的md5值
    "url":"图片地址",                          //阅后即焚的图片地址
    "fired":false                             //标记在查看前是否焚毁,一般都为false,可以不理会
  }
}
————————————————
贴图表情(type = 3):
{"attach":"{\"type\":3,\"data\":{\"catalog\":\"xxy\",\"chartlet\":\"xxy002\"}}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1458815489454","msgType":"CUSTOM","msgidClient":"e9ff8a99-1fc2-4646-8907-3312f4538c09","msgidServer":"8414888","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "type":3                                    //type=3表示是贴图表情
  "data": {
    "catalog":"xxy",                          //贴图所在文件夹的名称
    "chartlet":"xxy002"                       //贴图文件的名称
  }
}
————————————————
白板会话(type = 4)::
{"attach":"{\"type\":4,\"data\":{\"flag\":0}}","body":"","convType":"PERSON","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456904076370","msgType":"CUSTOM","msgidClient":"5545d9c6-7700-45bd-9fff-7e18294f159b","msgidServer":"8365186","resendFlag":"0","to":"lisi"}

attach字段释义:
{
  "type":4                            //type=4表示是白板会话
  "data": {
    "flag":0                          //0:邀请白板会话;1:关闭白板会话
  }
}

1.4.5.8、P2P:自定义系统通知

抄送示例:
{"attach":"{\"myKey1\":\"myValue1\",\"myKey2\":10}","body":"","convType":"CUSTOM_PERSON","customApnsText":"","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456913798613","msgType":"CUSTOM_P2P_MSG","msgidServer":"381209","to":"lisi"}

1.4.6.1、群组:文本消息

抄送示例:
{"attach":"","body":"文本消息","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456914408870","msgType":"TEXT","msgidClient":"f4c98f2c-b2bf-4d22-8cca-cb5c32e7aa3a","msgidServer":"780543197190","resendFlag":"0","tMembers":"[lisi]","to":"11631"}

tMembers字段说明:tMembers字段为群内除发送者外所有的有效群成员帐号的JSONArray串,以下群消息中的tMembers字段为相同概念,下略。

1.4.6.2、群组:图片消息

抄送示例:
{"attach":"{\"md5\":\"d0323f8d447abf3df7256bd66f9d5b62\",\"h\":500,\"ext\":\"jpg\",\"size\":9093,\"w\":500,\"name\":\"图片发送于2016-03-02 18:29\",\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl84NzBmZjY5Ni0yOGI5LTRiZDgtYjQ4Yy02ZmVjYWI0NjcxM2Y=\"}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456914540323","msgType":"PICTURE","msgidClient":"b3b1f911-d174-4417-9ffc-8f0e2b8becf5","msgidServer":"779603673092","resendFlag":"0","tMembers":"[lisi]","to":"11617"}

attach字段释义:参考P2P消息中的图片消息中attach字段释义

1.4.6.3、群组:音频消息

抄送示例:
{"attach":"{\"size\":13738,\"ext\":\"aac\",\"dur\":3808,\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl9lOWExMmNmMy1lZDhkLTQ2Y2UtYWRiYS1mOTA4ODhjZTliNTM=\",\"md5\":\"35411b36f22077309daec3b970b46e89\"}","body":"发来了一段语音","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456914620057","msgType":"AUDIO","msgidClient":"652d7015-9ee8-4e25-b1e7-40a3b534f4a5","msgidServer":"779603673093","resendFlag":"0","tMembers":"[lisi]","to":"11617"}

attach字段释义:参考P2P消息中的音频消息中attach字段释义

1.4.6.4、群组:视频消息

抄送示例:
{"attach":"{\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl9hMmJhOTIzMS1mM2NkLTQ0MTctOWI0OC1kZWRhOTFjNGUzZjA=\",\"md5\":\"6ba2b50225469d46263ba70736c37cd3\",\"ext\":\"mp4\",\"h\":480,\"size\":150495,\"w\":360,\"name\":\"视频发送于2016-03-02 18:31\",\"dur\":1473}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456914687808","msgType":"VIDEO","msgidClient":"d4ce8255-b9f8-4682-8ba2-a60f31be454a","msgidServer":"779603673094","resendFlag":"0","tMembers":"[lisi]","to":"11617"}

attach字段释义:参考P2P消息中的视频消息中attach字段释义

1.4.6.5、群组:地理位置消息

抄送示例:
{"attach":"{\"lat\":30.18704515647036,\"lng\":120.1908686708565,\"title\":\"中国 浙江省 杭州市 网商路 599号\"}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"REST","fromDeviceId":"","fromNick":"zhangsan","msgTimestamp":"1456914808531","msgType":"LOCATION","msgidClient":"1bc0a22a-e255-4ac7-8638-6ba3e9648550","msgidServer":"780543197191","resendFlag":"0","tMembers":"[lisi]","to":"11631"}

attach字段释义:参考P2P消息中的地理位置消息中attach字段释义

1.4.6.6、群组:文件消息

抄送示例:
{"attach":"{\"ext\":\"ttf\",\"md5\":\"79d62a35fa3d34c367b20c66afc2a500\",\"name\":\"BlizzardReg.ttf\",\"size\":\"91680\",\"url\":\"http:\\/\\/nimtest.nos.netease.com\\/08c9859d-183f-4daa-9904-d6cacb51c95b\"}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"REST","fromDeviceId":"","fromNick":"zhangsan","msgTimestamp":"1456969602600","msgType":"FILE","msgidClient":"5abd008f-4d94-41a4-89f4-bc6aa3c5dc1f","msgidServer":"780543197192","resendFlag":"0","tMembers":"[lisi]","to":"11631"}

attach字段释义:参考P2P消息中的发送文件消息中attach字段释义

1.4.6.7、群组:自定义消息

抄送示例:
{"attach":"{\"myKey1\":\"myValue1\",\"myKey2\":10}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"REST","fromDeviceId":"","fromNick":"zhangsan","msgTimestamp":"1456969938208","msgType":"CUSTOM","msgidClient":"4e330c5e-7f71-4f69-a51b-e6c884760866","msgidServer":"780543197194","resendFlag":"0","tMembers":"[lisi]","to":"11631"}

attach字段释义:由第三方自己定义并解析相应的Key-Value值


SDK中定义的几类自定义消息释义:
————————————————
剪刀石头布(type = 1):
{"attach":"{\"type\":1,\"data\":{\"value\":3}}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456970142720","msgType":"CUSTOM","msgidClient":"f051c3ab-89a4-4278-b311-02d679f97898","msgidServer":"780543197195","resendFlag":"0","tMembers":"[lisi]","to":"11631"}

attach字段释义:
{
  "type":1                                    //type=1表示是剪刀石头布
  "data": {
    "value":3                                 //1:石头;2:剪刀;3:布
  }
}

————————————————
贴图表情(type = 3):
{"attach":"{\"type\":3,\"data\":{\"catalog\":\"xxy\",\"chartlet\":\"xxy001\"}}","body":"","convType":"TEAM","eventType":"1","fromAccount":"zhangsan","fromClientType":"IOS","fromDeviceId":"B0BFF2EB-E2E1-4063-9E73-92FB926BF388","fromNick":"zhangsan","msgTimestamp":"1456971231090","msgType":"CUSTOM","msgidClient":"a0989c85-f85a-43a6-8ba5-d2509cf30d4b","msgidServer":"780543197215","resendFlag":"0","tMembers":"[lisi]","to":"11631"}

attach字段释义:
{
  "type":3                                    //type=3表示是贴图表情
  "data": {
    "catalog":"xxy",                          //贴图所在文件夹的名称
    "chartlet":"xxy002"                       //贴图文件的名称
  }
}

1.4.5.8、群组:自定义系统通知

抄送示例:
{"attach":"{\"myKey1\":\"myValue1\",\"myKey2\":10}","body":"","convType":"CUSTOM_TEAM","customApnsText":"","customSafeFlag":"0","eventType":"1","fromAccount":"zhangsan","msgTimestamp":"1456972250344","msgType":"CUSTOM_TEAM_MSG","msgidServer":"382250","tMembers":"[lisi]","to":"11631"}

登录事件消息抄送

2. "eventType"="2"。需要单独开通,如有需要,请联系相关云信商务经理。
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"accid":"test","clientIp":"192.168.1.100","clientType":"PC","code":"200","eventType":"2","sdkVersion":"18","timestamp":"1452504942126"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"accid":"test","clientIp":"192.168.1.100","clientType":"PC","code":"200","eventType":"2","sdkVersion":"18","timestamp":"1452504942126"}' 'http://yunxinservice.com.cn/receiveMsg.action'
名称类型说明
eventType String值为2,表示是会话类型的消息
accid String发生登录事件的用户帐号,字符串类型
clientIp String登录时的ip地址
clientType String客户端类型: AOS、IOS、PC、WINPHONE、WEB、REST,字符串类型
code String登录事件的返回码,可转为Integer类型数据
sdkVersion String当前sdk的版本信息,字符串类型
timestamp String登录事件发生时的时间戳,可转为Long型数据

登出事件消息抄送

3. "eventType"="3"。需要单独开通,如有需要,请联系相关云信商务经理。
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"accid":"test","clientIp":"192.168.1.100","clientType":"PC","code":"200","eventType":"3","sdkVersion":"18","timestamp":"1452504942126"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"accid":"test","clientIp":"192.168.1.100","clientType":"PC","code":"200","eventType":"3","sdkVersion":"18","timestamp":"1452504942126"}' 'http://yunxinservice.com.cn/receiveMsg.action'
登出事件消息中,clientIp字段并不一定保证抄送;登录事件消息中的该字段是一定保证抄送的
名称类型说明
eventType String值为3,表示是会话类型的消息
accid String发生登出事件的用户帐号,字符串类型
clientIp String登出时的ip地址
clientType String客户端类型: AOS、IOS、PC、WINPHONE、WEB、REST,字符串类型
code String登出事件的返回码,可转为Integer类型数据
sdkVersion String当前sdk的版本信息,字符串类型
timestamp String登出事件发生时的时间戳,可转为Long型数据

聊天室消息抄送

4. "eventType"="4"
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"attach":"{\"type\":1,\"data\":{\"value\":3}}","eventType":"4","ext":"{\"type\":-2}","fromAccount":"zqpret1101","fromAvator":"","fromClientType":"WEB","fromExt":"","fromNick":"zhangsan","msgTimestamp":"1456123424339","msgType":"CUSTOM","msgidClient":"e4d9065fdb5fde927b16d87b7e861d46","resendFlag":"0","roleInfoTimetag":"1456123382533","roomId":"2016"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"attach":"{\"type\":1,\"data\":{\"value\":3}}","eventType":"4","ext":"{\"type\":-2}","fromAccount":"zhangsan","fromAvator":"","fromClientType":"WEB","fromExt":"","fromNick":"zhangsan","msgTimestamp":"1456123424339","msgType":"CUSTOM","msgidClient":"e4d9065fdb5fde927b16d87b7e861d46","resendFlag":"0","roleInfoTimetag":"1456123382533","roomId":"2016"}' 'http://yunxinservice.com.cn/receiveMsg.action'
聊天室类型消息中,并不是每个字段都会一定抄送,请注意对各字段的判空处理。
以下为一般情况下必有的字段:
eventType、attach、fromAccount、msgTimestamp、msgType、msgidClient、roomId
名称类型说明
eventType String值为4,表示是聊天室消息
attach String消息内容,若msgType为CUSTOM自定义消息,该字段为JSON格式;否则该字段为普通字符串类型
ext String第三方扩展字段, 格式不限,长度限制4096,字符串类型
fromAccount String消息发送者的账号,字符串类型
fromAvator String发送者的头像,字符串类型
fromClientType String客户端类型: AOS、IOS、PC、WINPHONE、WEB、REST,字符串类型
fromExt String发送者身份的扩展字段,开发者可以自定义,字符串类型
fromNick String发送方昵称,字符串类型
msgTimestamp String消息发送的时间戳
msgType String 消息类型:
TEXT、
PICTURE、
AUDIO、
VIDEO、
LOCATION 、
NOTIFICATION、
FILE、 //文件消息
NETCALL_AUDIO、 //网络电话音频聊天
NETCALL_VEDIO、 //网络电话视频聊天
DATATUNNEL_NEW、 //新的数据通道请求通知
TIPS、 //提醒类型消息
CUSTOM //自定义消息
msgidClient String客户端生成的消息id
resendFlag String重发标记:0不是重发, 1是重发
roleInfoTimetag String消息发送者用户名片的最后更新时间,可转为Long型数据
roomId String消息所属的聊天室id,可转为Long型数据
antispam String标识是否被反垃圾,仅在被反垃圾时才有此字段,可转为Boolean类型数据

4.4.1、聊天室:发送文本消息

抄送示例:
{"attach":"聊天室文本消息","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456986458240","msgType":"TEXT","msgidClient":"wangwue-12345-9876543210123","resendFlag":"0","roleInfoTimetag":"0","roomId":"64"}

attach字段释义:参考P2P消息中的文本消息中attach字段释义

4.4.2、聊天室:发送图片消息

抄送示例:
{"attach":"{\"md5\":\"d0323f8d447abf3df7256bd66f9d5b62\",\"h\":500,\"ext\":\"jpg\",\"size\":9093,\"w\":500,\"name\":\"图片发送于2016-03-02 18:29\",\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl84NzBmZjY5Ni0yOGI5LTRiZDgtYjQ4Yy02ZmVjYWI0NjcxM2Y=\"}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456974764820","msgType":"PICTURE","msgidClient":"abcde-12345-987654","resendFlag":"0","roleInfoTimetag":"0","roomId":"113"}

attach字段释义:参考P2P消息中的图片消息中attach字段释义

4.4.3、聊天室:发送音频消息

抄送示例:
{"attach":"{\"size\":13738,\"ext\":\"aac\",\"dur\":3808,\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl9lOWExMmNmMy1lZDhkLTQ2Y2UtYWRiYS1mOTA4ODhjZTliNTM=\",\"md5\":\"35411b36f22077309daec3b970b46e89\"}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456983964169","msgType":"AUDIO","msgidClient":"abcde-12345-98765432","resendFlag":"0","roleInfoTimetag":"0","roomId":"113"}

attach字段释义:参考P2P消息中的音频消息中attach字段释义

4.4.4、聊天室:发送视频消息

抄送示例:
{"attach":"{\"dur\":1473,\"ext\":\"mp4\",\"h\":480,\"md5\":\"6ba2b50225469d46263ba70736c37cd3\",\"size\":150495,\"url\":\"http:\\/\\/b12026.nos.netease.com\\/MTAxMTAxMA==\\/bmltYV8xNDI5MTVfMTQ1NTY4NzIxMDkyNl9hMmJhOTIzMS1mM2NkLTQ0MTctOWI0OC1kZWRhOTFjNGUzZjA=\",\"w\":360}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456985454300","msgType":"VIDEO","msgidClient":"abcde-12345-9876543210","resendFlag":"0","roleInfoTimetag":"0","roomId":"64"}

attach字段释义:参考P2P消息中的视频消息中attach字段释义

4.4.5、聊天室:发送地理位置信息

抄送示例:
{"attach":"{\"lat\":30.18704515647036,\"lng\":120.1908686708565,\"title\":\"中国 浙江省 杭州市 网商路 599号\"}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456986934675","msgType":"LOCATION","msgidClient":"abcde-12345-98765432101234567","resendFlag":"0","roleInfoTimetag":"0","roomId":"64"}

attach字段释义:参考P2P消息中的地理位置消息中attach字段释义

4.4.6、聊天室:发送文件

抄送示例:
{"attach":"{\"ext\":\"ttf\",\"md5\":\"79d62a35fa3d34c367b20c66afc2a500\",\"name\":\"BlizzardReg.ttf\",\"size\":\"91680\",\"url\":\"http:\\/\\/nimtest.nos.netease.com\\/08c9859d-183f-4daa-9904-d6cacb51c95b\"}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456987025760","msgType":"FILE","msgidClient":"abcde-12345-987654321012345678","resendFlag":"0","roleInfoTimetag":"0","roomId":"64"}

attach字段释义:参考P2P消息中的发送文件消息中attach字段释义

4.4.7、聊天室:发送自定义消息

抄送示例:
{"attach":"{\"myKey1\":\"myValue1\",\"myKey2\":10}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456987119256","msgType":"CUSTOM","msgidClient":"abcde-12345-9876543210123456789","resendFlag":"0","roleInfoTimetag":"0","roomId":"64"}
attach字段释义:由第三方自己定义并解析相应的Key-Value值


SDK中定义的几类自定义消息释义:
————————————————
剪刀石头布(type = 1):
{"attach":"{\"type\":1,\"data\":{\"value\":3}}","eventType":"4","ext":"{\"type\":-2}","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"IOS","fromExt":"","fromNick":"zhangsan","msgTimestamp":"1456987221992","msgType":"CUSTOM","msgidClient":"aba76741-f5c4-40ce-9f84-4b76c89d9b71","resendFlag":"0","roleInfoTimetag":"1456987212647","roomId":"64"}

attach字段释义:
{
"type":1                                    //type=1表示是剪刀石头布
"data": {
    "value":3                                 //1:石头;2:剪刀;3:布
  }
}

————————————————
贴图表情(type = 3):
{"attach":"{\"type\":3,\"data\":{\"catalog\":\"xxy\",\"chartlet\":\"xxy001\"}}","eventType":"4","ext":"","fromAccount":"zhangsan","fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8xNDI5MTZfMTQzODg2NDI4ODE0Ml81NjM3ZTIxMC1iMjE5LTRhYjgtOGZlOS02MzBjZWFjYmMwZDE=","fromClientType":"REST","fromNick":"zhangsan","msgTimestamp":"1456987840942","msgType":"CUSTOM","msgidClient":"abcde-12345-987654321012345678901","resendFlag":"0","roleInfoTimetag":"0","roomId":"64"}

attach字段释义:
{
"type":3                                    //type=3表示是贴图表情
"data": {
    "catalog":"xxy",                          //贴图所在文件夹的名称
    "chartlet":"xxy002"                       //贴图文件的名称
  }
}

音视频/白板时长消息抄送

5. "eventType"="5"

抄送情景说明

会抄送时长消息的场景:

1. 主被叫接通,正常结束(通话时长大于0),抄送时长、主被叫账号;
2. 主被叫接通,接通的同时立刻挂断(双方都成功进入频道,通话时长为0),抄送时长及主被叫账号。备注:立即挂断时,时长也可能不为03. 主被叫接通时出现异常(如:接通时一方网络出现问题),只有一个人成功进入频道(单人进入,抄送时长为0,status是SINGLE_PARTICIPATE),抄送时长,不抄送主被叫账号。

不会抄送时长消息的场景:

1. 被叫拒接;
2. 被叫超时未接听,通话结束;
3. 被叫接听前主叫挂断;
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"channelId":"6265489843204131361","createtime":"1458798033925","duration":"25","eventType":"5","live":"1","members":"[{\"accid\":\"lisi\",\"duration\":13},{\"accid\":\"zhangsan\",\"caller\":true,\"duration\":12}]","status":"SUCCESS","type":"AUDIO"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"channelId":"6265489843204131361","createtime":"1458798033925","duration":"25","eventType":"5","live":"0","members":"[{\"accid\":\"lisi\",\"duration\":13},{\"accid\":\"zhangsan\",\"caller\":true,\"duration\":12}]","status":"SUCCESS","type":"AUDIO"}' 'http://yunxinservice.com.cn/receiveMsg.action'
名称类型说明
channelId String通道号
createtime String音视频通话/白板开始的事件, 可转为13位时间戳
duration String此通通话/白板的通话时长,精确到秒,可转为Integer类型
eventType String为5,表示是实时音视频/白板时长类型事件
live String是否是互动直播的音视频,0:否,1:是
members String 表示通话/白板的参与者:
accid为用户帐号;
如果是通话的发起者的话,caller字段为true,否则无caller字段;
duration表示对应accid用户的单方时长,其中白板消息暂无此单方时长的统计
status String 通话/白板状态:
SUCCESS:表示正常挂断;
TIMEOUT:表示超时;
SINGLE_PARTICIPATE:表示只有一个参与者;
UNKNOWN:表示未知状态
type String 类型:
AUDIO:表示音频通话;
VEDIO:表示视频通话;
DataTunnel:表示白板事件

5.4.1、实时音频通话时长消息

抄送示例:
{"channelId":"6265489843204131361","createtime":"1458798033925","duration":"25","eventType":"5","live":"0","members":"[{\"accid\":\"lisi\",\"duration\":13},{\"accid\":\"zhangsan\",\"caller\":true,\"duration\":12}]","status":"SUCCESS","type":"AUDIO"}

5.4.2、实时视频通话时长消息

抄送示例:
{"channelId":"6265490045067594274","createtime":"1458798080073","duration":"22","eventType":"5","live":"1","members":"[{\"accid\":\"lisi\",\"duration\":11},{\"accid\":\"zhangsan\",\"caller\":true,\"duration\":11}]","status":"SUCCESS","type":"VEDIO"}

5.4.3、白板时长消息

抄送示例:
{"channelId":"6668145522152249926","createtime":"1473385450643","duration":"12","eventType":"5","members":"[{\"accid\":\"zhangsan\",\"duration\":6},{\"accid\":\"lisi\",\"caller\":true,\"duration\":6}]","status":"SUCCESS","type":"DataTunnel"}

音视频/白板文件下载信息抄送

6. "eventType"="6"
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"eventType":"6","fileinfo":"[{\"caller\":true,\"channelid\":\"6290737000999815988\",\"filename\":\"243494-6290737000999815988.gz\",\"md5\":\"a9b248e29669d588dd0b10259dedea1a\",\"mix\":false,\"size\":\"2167\",\"type\":\"gz\",\"url\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8yNDM0OTRfNjI5MDczNzAwMDk5OTgxNTk4OF8xNDY0Njc2NTM5OTQ0XzZiMzdiMTk1LWQ5ZDUtNDFmMC1iNzIzLTRiYmY5ODViNDBiMA==?download=243494-6290737000999815988.gz\",\"user\":\"zhangsan\"}]"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"eventType":"6","fileinfo":"[{\"caller\":true,\"channelid\":\"6290737000999815988\",\"filename\":\"243494-6290737000999815988.gz\",\"md5\":\"a9b248e29669d588dd0b10259dedea1a\",\"mix\":false,\"size\":\"2167\",\"type\":\"gz\",\"url\":\"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV8yNDM0OTRfNjI5MDczNzAwMDk5OTgxNTk4OF8xNDY0Njc2NTM5OTQ0XzZiMzdiMTk1LWQ5ZDUtNDFmMC1iNzIzLTRiYmY5ODViNDBiMA==?download=243494-6290737000999815988.gz\",\"user\":\"zhangsan\"}]"}' 'http://yunxinservice.com.cn/receiveMsg.action'
名称类型说明
eventType String值为6,表示是音视频/白板文件下载信息类型的消息
fileinfo String 可转为JSONArray,其中的字段释义如下:
caller:是否是此通通话的发起者,若是则为true,若不是则没有此字段,可转为Boolean值
channelid:通道号,可转为Long值
filename:文件名,直接存储,混合录制文件filename带有"-mix"标记
md5:文件的md5值
size:文件大小,单位为字符,可转为Long值
type:文件的类型(扩展名),包括aac、gz、mp4,分别表示音频、白板、视频
url:文件的下载地址
user:用户帐号,若该文件为混合录制文件,则该字段为"0"
mix:是否为混合录制文件,true:混合录制文件;false:单人录制文件

主播或管理员进出聊天室事件抄送

7. "eventType"="9"  --> 特别注意!这里的eventType是9
POST  /receiveMsg.action   HTTP/1.1
Host:  yunxinservice.com.cn
Content-Type:  application/json
CurTime: 1440570500855    //当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的毫秒数(String)
MD5: feec2cda404d7417b8b427e95748bb56     //根据请求中的request body计算出来的MD5值
CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01

{"roomId":"1001","event":"IN","accid":"test","clientIp":"192.168.1.100","clientType":"PC","code":"200","eventType":"9","sdkVersion":"18","timestamp":"1452504942126"}
curl -X POST -H "Content-Type: application/json" -H "CurTime: 1440570500855" -H "MD5: feec2cda404d7417b8b427e95748bb56" -H "CheckSum: 001511b8435e0b28044ca50a78e8f983026c5e01" -d '{"roomId":"1001","event":"IN","accid":"test","clientIp":"192.168.1.100","clientType":"PC","code":"200","eventType":"9","sdkVersion":"18","timestamp":"1452504942126"}' 'http://yunxinservice.com.cn/receiveMsg.action'
名称类型说明
eventType String值为9,特别注意这里是9,表示是一个主播或管理员进出聊天室事件
roomId String聊天室id
event String进入或退出。IN:进入聊天室;OUT:主动退出聊天室,或掉线
accid String用户帐号,字符串类型
clientIp String客户端的ip地址,OUT时不保证能提供此字段
clientType String客户端类型: AOS、IOS、PC、WINPHONE、WEB、REST,字符串类型
code String返回码,可转为Integer类型数据
sdkVersion String当前sdk的版本信息,字符串类型
timestamp String事件发生时的时间戳,可转为Long型数据

语音视频通话

说明

1.语音视频服务属于收费功能,使用前需要联系客服开通功能;
2.加入频道支持安全模式和非安全模式两种:

为了您的账号安全,我们推荐您使用安全模式 。

获取语音视频安全认证签名

请求说明

POST https://api.netease.im/nimserver/user/getToken.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

请求中Headers的设置请参考接口概述

接口描述

获取语音视频安全认证模式下的签名。

参数说明

参数类型必须说明
uidlong用户帐号唯一标识

curl请求示例

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'uid=123456' 'https://api.netease.im/nimserver/user/getToken.action'

返回说明

Http响应JSON格式

"Content-Type": "application/json; charset=utf-8"
{
   "code":200"token":"xxxxx"  //安全认证模式下的签名。
}

主要的返回码

200、403、414、416、431、500

具体请参考code状态表


code状态表

code 详细描述
200 操作成功
201 客户端版本不对,需升级sdk
301 被封禁
302 用户名或密码错误
315 IP限制
403 非法操作或没有权限
404 对象不存在
405 参数长度过长
406 对象只读
408 客户端请求超时
413 验证失败(短信服务)
414 参数错误
415 客户端网络问题
416 频率控制
417 重复操作
418 通道不可用(短信服务)
419 数量超过上限
422 账号被禁用
431 HTTP重复请求
500 服务器内部错误
503 服务器繁忙
514 服务不可用
509 无效协议
998 解包错误
999 打包错误
群相关错误码
801 群人数达到上限
802 没有权限
803 群不存在
804 用户不在群
805 群类型不匹配
806 创建群数量达到限制
807 群成员状态错误
808 申请成功
809 已经在群内
810 邀请成功
音视频、白板通话相关错误码
9102 通道失效
9103 已经在他端对这个呼叫响应过了
11001 通话不可达,对方离线状态
聊天室相关错误码
13001 IM主连接状态异常
13002 聊天室状态异常
13003 账号在黑名单中,不允许进入聊天室
13004 在禁言列表中,不允许发言
特定业务相关错误码
10431 输入email不是邮箱
10432 输入mobile不是手机号码
10433 注册输入的两次密码不相同
10434 企业不存在
10435 登陆密码或帐号不对
10436 app不存在
10437 email已注册
10438 手机号已注册
10441 app名字已经存在