目录

服务端集成

直播聊天室提供REST API形式的管理接口,下面是关于服务端直播聊天室的管理功能说明。

服务端介绍

直播聊天室是基于环信聊天室之上构建的功能,一个直播聊天室涉及聊天室、直播聊天室、直播场次三个概念。

聊天室

即环信的聊天室功能,每一个直播聊天室,都唯一对应一个聊天室(反过来不成立)。 直播聊天室复用了对应聊天室的所有资源,包括聊天室的成员列表等。

强烈不建议调用解散聊天室接口。将直播聊天室对应的聊天室解散,这将导致该直播聊天室数据遭到破坏、不完整等异常情况。

关于聊天室REST API,请参考聊天室管理

直播聊天室

维护直播聊天室的ID、标题、描述、封面、进入是否需要密码等信息。

直播场次

直播聊天室是以直播场次为基本单位的。每开始一场新的直播,后台创建一个新的直播场次。

直播场次相关的信息包括该直播场次的ID、主播ID、直播开始时间、直播结束时间、直播状态,以及本场直播的点赞数量,观看人数等统计指标。

直播场次的状态:not_start:未开始;ongoing:正在进行中;completed:已结束,completed表示直播房间正常的直播结束,成员还留在直播聊天室中;closed:已关闭,closed表示强制关闭当前直播场次,成员会被踢出直播聊天室。

新建一个直播场次,之前的直播场次状态必须是completed 或者 closed,否则无法创建。新创建一个直播聊天室的同时,后台会自动创建一个直播场次。

直播聊天室的状态,是指直播聊天室的当前直播场次的状态。

主播

直播聊天室的主播,与该直播聊天室对应聊天室的群主是同一人。除了app管理员之外,只有主播才能创建直播聊天室。可以通过新建主播接口,为一个普通IM用户增加主播这个角色。

一个直播聊天室只能有一个主播,但可以有多个候选主播。候选主播可以不是聊天室的成员。可以通过关联接口,将一个主播与一个直播聊天室关联,关联后主播即成为该直播聊天室的候选主播。

您可以从直播聊天室的关联主播列表中,选择一个主播,通过调用“主播绑定直播聊天室”接口,将其变成聊天室的(正式)主播。

就像群主可以退出聊天室一样,主播也可以退出直播聊天室,但角色保留:他仍然是该直播聊天室的主播。 

REST API介绍

直播流地址

设置直播流地址

调用说明
API示例

请求:

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/stream_url -d '{"pc_pull":"rtmp://publish3.cdn.ucloud.com.cn/ucloud","pc_push":"rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud","mobile_pull":"rtmp://publish3.cdn.ucloud.com.cn/ucloud","mobile_push":"rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud"}'"

响应:

{
    "action": "post", 
    "application": "e1a09de0-0e03-11e7-ad8e-a1d913615409", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/stream_url", 
    "entities": [ ], 
    "data": {
        "pc_pull": true, 
        "mobile_push": true, 
        "mobile_pull": true, 
        "pc_push": true
    }, 
    "timestamp": 1494084474885, 
    "duration": 1, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员

字段说明

获取某端直播流地址

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/stream_url?type=mobile_pull"

响应:

{
    "action": "get", 
    "application": "e1a09de0-0e03-11e7-ad8e-a1d913615409", 
    "params": {
        "type": [
            "mobile_pull"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/stream_url", 
    "entities": [ ], 
    "data": {
        "mobile_pull": "rtmp://publish3.cdn.ucloud.com.cn/ucloud"
    }, 
    "timestamp": 1494084603633, 
    "duration": 1, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 0
}
权限要求

app管理员

直播聊天室管理

创建直播聊天室

提示:在创建直播聊天室之前,必须首先设置直播流地址。

调用说明
API示例

请求:

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  -d '{"title":"test_liveroom_1","desc":"this is a test live room", "anchor":"z1"}' "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms?status=ongoing"

响应:

{
    "action": "post", 
    "application": "e1a09de0-0e03-11e7-ad8e-a1d913615409", 
    "params": {
        "status": [
            "ongoing"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms", 
    "entities": [ ], 
    "data": {
        "liveroom_id": "2", 
        "chatroom_id": "15399890518017", 
        "pc_pull_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1", 
        "pc_push_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1", 
        "mobile_pull_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1", 
        "mobile_push_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1"
    }, 
    "timestamp": 1494084880158, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员、主播

请求字段说明

必填字段:

选填字段:

响应字段说明

修改直播聊天室

调用说明
API示例

请求:

curl -X PUT -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  -d '{"chatroom":{"max_users":400},"liveroom":{"title":"sing a song", "need_password":true, "password":"123456"}, "liveshow":{"start_time":1567685678000}}' "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/2"

响应:

{
    "action": "put", 
    "application": "e1a09de0-0e03-11e7-ad8e-a1d913615409", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/2", 
    "entities": [ ], 
    "data": {
        "start_time": true, 
        "password": true, 
        "need_password": true, 
        "title": true, 
        "max_users": true
    }, 
    "timestamp": 1494085338811, 
    "duration": 1, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员,当前聊天室的主播或者管理员

可修改字段说明

chatroom(聊天室相关):

liveroom(直播聊天室相关):

liveshow(直播场次相关):

获取直播聊天室详情

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo" "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/2"

响应:

{
    "action": "get", 
    "application": "e1a09de0-0e03-11e7-ad8e-a1d913615409", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/2", 
    "entities": [ ], 
    "data": {
        "id": "2", 
        "chatroom_id": "15399890518017", 
        "title": "sing a song", 
        "desc": "this is a test live room", 
        "max_users": 400, 
        "current_users": 1, 
        "status": "ongoing", 
        "anchor": "z1", 
        "passwordEnable": true, 
        "startTime": 1567685678000, 
        "endTime": 1494084880154, 
        "cover_picture_url": "", 
        "pc_pull_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1", 
        "pc_push_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1", 
        "mobile_pull_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1", 
        "mobile_push_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_2_1"
    }, 
    "timestamp": 1494086098297, 
    "duration": 2, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 0
}
权限要求

聊天室成员、app管理员

删除直播聊天室

调用说明
API示例

请求:

curl -X DELETE -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo" "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1968"

响应:

{
    "action": "delete", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1968", 
    "entities": [ ], 
    "data": {
        "liveRoomID": "1968", 
        "result": true
    }, 
    "timestamp": 1496232654706, 
    "duration": 1, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

直播聊天室主播、app管理员

分页获取直播聊天室列表

获取全部的直播聊天室列表,不区分直播聊天室状态。

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo" "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms?pagenum=2&pagesize=2"

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "pagesize": [
            "2"
        ], 
        "pagenum": [
            "2"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms", 
    "entities": [ ], 
    "data": [
        {
            "id": "1962", 
            "chatroom_id": "17638557286401", 
            "title": "123456", 
            "desc": "fbhjj", 
            "startTime": 1496219839053, 
            "endTime": 1496219930994, 
            "anchor": "quest1919", 
            "gift_count": 0, 
            "praise_count": 0, 
            "current_user_count": 1, 
            "max_user_count": 2, 
            "status": "completed", 
            "cover_picture_url": "", 
            "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1962_1", 
            "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1962_1", 
            "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1962_1", 
            "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1962_1"
        }, 
        {
            "id": "1961", 
            "chatroom_id": "17637486690306", 
            "title": "vv", 
            "desc": "ddd", 
            "startTime": 1496220731055, 
            "endTime": 1496220771419, 
            "anchor": "mnabc", 
            "gift_count": 0, 
            "praise_count": 0, 
            "current_user_count": 1, 
            "max_user_count": 2, 
            "status": "completed", 
            "cover_picture_url": "", 
            "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1961_3", 
            "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1961_3", 
            "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1961_3", 
            "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1961_3"
        }
    ], 
    "timestamp": 1496233296564, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 2
}
权限要求

普通用户、app管理员

分页获取正在直播的直播聊天室列表

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo" "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms?ongoing=true&limit=2&cursor=ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6MjE"

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "cursor": [
            "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6MjE"
        ], 
        "ongoing": [
            "true"
        ], 
        "limit": [
            "2"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms", 
    "entities": [ ], 
    "data": [
        {
            "id": "1946", 
            "chatroom_id": "17290386014210", 
            "title": "呃呃呃", 
            "desc": "你w", 
            "startTime": 1495887797479, 
            "endTime": 1495887797479, 
            "anchor": "hhhhhr", 
            "gift_count": 0, 
            "praise_count": 0, 
            "current_user_count": 2, 
            "max_user_count": 3, 
            "status": "ongoing", 
            "cover_picture_url": "", 
            "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1946_1", 
            "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1946_1", 
            "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1946_1", 
            "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1946_1"
        }, 
        {
            "id": "1941", 
            "chatroom_id": "17276864626689", 
            "title": "trbTest", 
            "desc": "trbTest", 
            "startTime": 1495875721150, 
            "endTime": 1495875721150, 
            "anchor": "trb", 
            "gift_count": 0, 
            "praise_count": 0, 
            "current_user_count": 0, 
            "max_user_count": 1, 
            "status": "ongoing", 
            "cover_picture_url": "http://127.0.0.1/easemob-demo/chatdemoui/chatfiles/38dcb1e0-42b9-11e7-9642-258f3a183287", 
            "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1941_4", 
            "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1941_4", 
            "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1941_4", 
            "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1941_4"
        }
    ], 
    "timestamp": 1496233924583, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "cursor": "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6Mjg", 
    "count": 2
}
权限要求

普通用户、app管理员

获取直播聊天室的直播状态

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo" "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1946/status"

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1946/status", 
    "entities": [ ], 
    "data": {
        "liveRoomID": "1946", 
        "status": "ongoing"
    }, 
    "timestamp": 1496234759930, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 0
}

其中,status值的范围: not_start, ongoing, completed, closed

权限要求

普通用户、app管理员

更新直播聊天室的直播状态

调用说明
API示例

请求:

curl -X PUT -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo" "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/status"  -d '{"status":"ongoing"}'

响应:

{
    "action": "put", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/status", 
    "entities": [ ], 
    "data": {
        "liveRoomID": "1970", 
        "status": "ongoing"
    }, 
    "timestamp": 1496235373581, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 0
}
权限要求

直播聊天室主播、app管理员

新建直播场次

新创建的直播聊天室,会默认创建一个直播场次,状态是not_start;如果当前直播聊天室的状态是ongoing,则不允许创建新的直播场次,此时需要将其状态设置为completed或者closed,再创建新的直播场次。

调用说明
API示例

请求:

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/liveshows?status=ongoing -d '{ "anchor":"z2", "title":"sing a love song", "desc":"this is a new live show"}'

响应:

{
    "action": "post", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "status": [
            "ongoing"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/liveshows", 
    "entities": [ ], 
    "data": {
        "liveshow_id": "2", 
        "chatroom_id": "17654613082113", 
        "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1970_2", 
        "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1970_2", 
        "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1970_2", 
        "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1970_2"
    }, 
    "timestamp": 1496236098889, 
    "duration": 1, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员、主播

请求字段说明

必填字段:

响应字段说明

获取appkey下正在直播的直播聊天室列表

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms?ongoing=true&limit=2&cursor=ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6MzE

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "cursor": [
            "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6MzE"
        ], 
        "ongoing": [
            "true"
        ], 
        "limit": [
            "2"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms", 
    "entities": [ ], 
    "data": [
        {
            "id": "1924", 
            "chatroom_id": "17177265635330", 
            "title": "具体了", 
            "desc": "就咯", 
            "startTime": 1495779917352, 
            "endTime": 1495779917352, 
            "anchor": "wuls", 
            "gift_count": 0, 
            "praise_count": 0, 
            "current_user_count": 8, 
            "max_user_count": 9, 
            "status": "ongoing", 
            "cover_picture_url": "", 
            "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1924_1", 
            "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1924_1", 
            "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1924_1", 
            "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1924_1"
        }, 
        {
            "id": "1922", 
            "chatroom_id": "17175003856897", 
            "title": "香山", 
            "desc": "随便", 
            "startTime": 1495777760957, 
            "endTime": 1495777760957, 
            "anchor": "sx001", 
            "gift_count": 0, 
            "praise_count": 8, 
            "current_user_count": 1, 
            "max_user_count": 3, 
            "status": "ongoing", 
            "cover_picture_url": "http://127.0.0.1:8080/easemob-demo/chatdemoui/chatfiles/43a62c20-41d6-11e7-a88e-df409c88cf66", 
            "pc_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1922_1", 
            "pc_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1922_1", 
            "mobile_pull_url": "rtmp://vlive3.rtmp.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1922_1", 
            "mobile_push_url": "rtmp://publish3.cdn.ucloud.com.cn/ucloud/easemob-demo_chatdemoui_1922_1"
        }
    ], 
    "timestamp": 1496303336669, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "cursor": "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6NDk", 
    "count": 2
}
权限要求

appKey下普通用户

主播管理

新建主播

给一个普通IM用户赋予主播权限,只有拥有主播权限的用户,才能创建直播聊天室。

调用说明
API示例

请求:

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/chatrooms/super_admin -d'{"superadmin":"z10"}'

响应:

{
    "action": "post", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/chatrooms/super_admin", 
    "entities": [ ], 
    "data": {
        "result": "success"
    }, 
    "timestamp": 1496236798886, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员

分页获取appKey下的主播列表

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors?pagenum=2&pagesize=2

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "pagesize": [
            "2"
        ], 
        "pagenum": [
            "2"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors", 
    "entities": [ ], 
    "data": [
        "no88", 
        "no3"
    ], 
    "timestamp": 1496242313900, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 2
}
权限要求

app管理员

移除主播角色

移除用户的主播角色,用户不会被删除,变成普通IM用户。

调用说明
API示例

请求:

curl -X DELETE -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z10

响应:

{
    "action": "delete", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z10", 
    "entities": [ ], 
    "data": {
        "action": "remove_anchor", 
        "username": "z10", 
        "result": true
    }, 
    "timestamp": 1496291020316, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员

主播关联直播聊天室

关联后,主播变成该直播聊天室的候选主播。

调用说明
API示例

请求:

curl -X PUT -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z2/join/1970

响应:

{
    "action": "post", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z2/join/1970", 
    "entities": [ ], 
    "data": {
        "anchor": "z2", 
        "action": "join_liveroom", 
        "result": "true"
    }, 
    "timestamp": 1496291884125, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员

主播取消关联直播聊天室

调用说明
API示例

请求:

curl -X DELETE -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z2/release/1970

响应:

{
    "action": "delete", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z2/release/1970", 
    "entities": [ ], 
    "data": {
        "anchor": "z2", 
        "action": "release_liveroom", 
        "result": "true"
    }, 
    "timestamp": 1496292688964, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}
权限要求

app管理员

获取主播关联的直播聊天室列表

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z10/joined_liveroom_list?pagenum=1&pagesize=2

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "pagesize": [
            "2"
        ], 
        "pagenum": [
            "1"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/anchors/z10/joined_liveroom_list", 
    "entities": [ ], 
    "data": [
        "1970"
    ], 
    "timestamp": 1496297526259, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 1
}
权限要求

app管理员、主播

获取一个直播聊天室下的关联主播列表

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/anchors?pagenum=1&pagesize=2

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "pagesize": [
            "2"
        ], 
        "pagenum": [
            "1"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/anchors", 
    "entities": [ ], 
    "data": [
        {
            "anchor": "z10", 
            "nickname": " ", 
            "bind": true
        }, 
        {
            "anchor": "z1", 
            "nickname": "z1", 
            "bind": false
        }
    ], 
    "timestamp": 1496297733753, 
    "duration": 1, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "count": 2
}
权限要求

app管理员

主播绑定直播聊天室

绑定直播聊天室,主播即变成这个直播聊天室的正式主播,原有主播被移除。这个接口和“主播关联直播聊天室”不同,后者表示主播变成了直播聊天室的候选主播而不是正式的主播。

调用说明
API示例

请求:

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/anchors/z10

响应:

{
    "action": "post", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/anchors/z10", 
    "entities": [ ], 
    "data": {
        "newOwner": "z10", 
        "oldOwner": "z1"
    }, 
    "timestamp": 1496291608951, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui"
}

其中,newOwner表示新的主播,oldOwner表示原有的主播。

权限要求

app管理员

用户管理

踢出聊天室

您可以首先获取到直播聊天室对应的聊天室ID,再调用聊天室的“获取管理员列表”接口。

具体操作如下:

获取直播聊天室在线普通用户列表

这个接口获取的是聊天室的普通成员,即不包括主播,以及管理员。另外,该接口只支持cursor方式的查询,不支持pagenum/pagesize方式的查询。

调用说明
API示例

请求:

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/users?limit=2&cursor=ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6Mg

响应:

{
    "action": "get", 
    "application": "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5", 
    "params": {
        "cursor": [
            "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6Mg"
        ], 
        "limit": [
            "2"
        ]
    }, 
    "uri": "http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/users", 
    "entities": [ ], 
    "data": [
        {
            "username": "15880431519", 
            "join_tm": 1496296756711, 
            "watch_duration_in_seconds": 1427, 
            "banned": false
        }, 
        {
            "username": "337457825", 
            "join_tm": 1496296502304, 
            "watch_duration_in_seconds": 1682, 
            "banned": false
        }
    ], 
    "timestamp": 1496298184581, 
    "duration": 0, 
    "organization": "easemob-demo", 
    "applicationName": "chatdemoui", 
    "cursor": "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06Y2hhdHJvb206ZWFzZW1vYi1kZW1vI2NoYXRkZW1vdWk6NA", 
    "count": 2
}

其中,username 表示用户名,join_tm表示用户最近加入的UNIX时间戳,watch_duration_in_seconds表示最近一次加入直播聊天室以来的观看时间,banned表示用户是否被禁言。

权限要求

聊天室所有成员、app管理员

管理员/禁言/黑名单

对直播聊天室的管理员、禁言、黑名单,均支持添加、删除、获取列表这三项操作,目前这些接口是对直播聊天室对应的聊天室相应同名接口的简单封装。

但我们还是强烈建议您使用以下接口进行相关操作,而不是直接调用直播聊天室对应的聊天室的同名接口。

添加管理员/禁言/黑名单

API示例

添加管理员请求

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/admin/z10

添加禁言请求(目前仅支持永久禁言)

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/mute/z10

添加黑名单请求

curl -X POST -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/blacklist/z10
权限要求

添加管理员需要当前直播聊天室主播,或者app管理员权限;添加禁言、黑名单,需要当前直播聊天室管理员、主播,或者app管理员权限。

移除管理员/禁言/黑名单

API示例

移除管理员请求

curl -X DELETE -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/admin/z10

移除禁言请求

curl -X DELETE -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/mute/z10

移除黑名单请求

curl -X DELETE -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/blacklist/z10
权限要求

移除管理员需要当前直播聊天室主播,或者app管理员权限;移除禁言、黑名单,需要当前直播聊天室管理员、主播,或者app管理员权限。

获取管理员/禁言/黑名单列表

API示例

获取管理员列表请求(不支持分页查询)

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/admin

获取禁言列表请求(注:需要先查询直播聊天室对应的聊天室ID,再使用聊天室的获取禁言列表接口)

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/chatrooms/15399890518017/mute?pagenum=2&pagesize=5

获取黑名单列表请求

curl -X GET -H "Authorization: Bearer YWMti2bp0NdNEea6On9r7PFKfAAAAVq-FyjtBdvG8hGqmEStXoaECQBgCHIBaqo"  http://127.0.0.1:8080/easemob-demo/chatdemoui/liverooms/1970/blacklist?pagenum=2&pagesize=5
权限要求

获取管理员列表需要当前直播聊天室主播,或者app管理员权限;获取禁言、黑名单列表,需要当前直播聊天室管理员、主播,或者app管理员权限。


上一页:产品介绍