简要描述:
- 创建直播室,获取直播室推流和观看协议链接
请求URL:
- /zhibo/rooms
HTTP请求方法:
- POST
请求头:
NA
URL请求参数:
NA
请求体参数:
参数名 | 是否必须 | 类型 | 输入校验 | 说明 |
---|---|---|---|---|
roomName | 是 | String | 最大长度100 | 直播间房间名称 |
roomCode | 否 | String | 长度11 | 直播间ID/Code, 不传值时自动生成,传值会验证长度和是否为字母或数字 |
description | 否 | String | 最大长度500 | 直播间房间描述 |
hostPassword | 否 | String | 最大长度32 | 设置直播主播密码 |
assistantPassword | 否 | String | 最大长度32 | 设置直播助理密码 |
playPassword | 否 | String | 最大长度32 | 设置直播观看密码 |
type | 否 | Integer | 数字 | 房间类型 (1=普通默认类型) |
roomCoverUrl | 否 | String | 最大长度500 | 直播室封面图片Url |
sessions[].sessionStartTime | 否, 若session不为空,则此字段必须 | String | 日期格式yyyy-MM-dd HH:mm:ss | 直播场次开始时间 |
sessions[].sessionEndTime | 否, 若session不为空,则此字段必须 | String | 日期格式yyyy-MM-dd HH:mm:ss | 直播场次结束时间 |
sessions[].hostName | 否 | String | 50 | 直播场次主讲人名称 |
sessions[].hostAvatarUrl | 否 | String | 500 | 直播场次主讲人头像 |
sessions[].sessionName | 否, 若session不为空,则此字段必须 | String | 100 | 直播场次名称 |
sessions[].sessionDesc | 否 | String | 500 | 直播场次简介 |
ad.adImgUrl | 否, 若ad不为空,则此字段必须 | String | 500 | 图链广告图片Url |
ad.adLink | 否 | String | 500 | 广告链接 |
ad.enableAd | 否 | int | 1 | 开启直播图链广告广告类型(1=直播间图链广告) |
ad.adLocation | 否 | int | 1 | 广告显示位置(1=左上角,2=右下角,3=左下角,4=右上角) |
返回参数说明:
返回201的成功创建的响应体:
参数名 | 类型 | 说明 |
---|---|---|
pid | String | 直播房间pid |
roomCode | String | 直播房间code编号 |
sessionId | String | 直播当前活动场次pid,当直播关闭后为空, 创建时为空 |
chatroomId | String | 直播当前活动聊天室id,当直播关闭后为空, 创建时为空 |
hostId | String | 直播当前活动主播id,当直播关闭后为空, 创建时为空 |
orgId | String | 直接所属机构appKey |
allowAnonym | int | 允许匿名1=允许,0=不允许 |
roomName | String | 直播间名称 |
sessionName | String | 直播场次名称, 创建时为空 |
description | String | 直播间描述 |
platform | int | 直播平台(1-PC端,2-移动端) |
status | int | 直接间状态(0-禁用,1-启用) |
streamStatus | int | 直播流状态(-1=无定义,0-未启用,1-已启用,2-使用中;当状态为未启用时,需要调用开始直播api启用房间;当已启用时,表示可以推流;当使用中时,表示房间在使用,有推流直播进行中) |
type | int | 直播间类型(1-默认,2=主持人房间,3=嘉宾房间,其它-待定) |
creator | String | 创建人(对应org的appkey) |
createTime | String | 创建时间 |
updater | String | 修改人(对应org的appkey) |
updateTime | String | 修改时间 |
sessions[].sessionStartTime | String | 直播场次开始时间 |
sessions[].sessionEndTime | String | 直播场次结束时间 |
sessions[].hostName | tring | 直播场次主讲人名称 |
sessions[].hostAvatarUrl | String | 直播场次主讲人头像 |
sessions[].sessionName | String | 直播场次名称 |
sessions[].sessionDesc | String | 直播场次简介 |
sessions[].pid | String | 直播场次主键pid |
sessions[].deletedFlag | int | 直播场次删除标记(0=未删除,1=删除) |
sessions[].appPushProtocal | String | 直播场次推流唤起协议地址 |
sessions[].appPullProtocal | String | 直播场次拉流唤起协议地址 |
sessions[].appAtPullProtocal | String | 直播场次助教拉流唤起协议地址 |
ad.adImgUrl | String | 图链广告图片Url |
ad.adLink | String | 广告链接 |
ad.enableAd | int | 开启直播图链广告广告类型(1=直播间图链广告) |
ad.adLocation | int | 广告显示位置(1=左上角,2=右下角,3=左下角,4=右上角) |
示例:
请求:
POST https://api-zhibo.yxt.com/v1/zhibo/rooms
Content-Type: application/json;charset=UTF-8
appkey: xxxxxxxxxxxxxxxxxxxxx
nonce: xxxx
timestamp: xxxxxxxxxx
signature: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
source: xxxx
请求体:
{
“roomName”: “直播创建测试”,
“description”: “直播创建测试desc”,
“hostPassword”: “123456”
}
正确时返回:
状态值: HTTP/1.1 201 Created 或200 OK.
Content-Type: application/json;charset=UTF-8
{
"allowAnonym": 1,
"createTime": "2017-10-18 09:52:06",
"creator": "6d95b35f095f4285b7eebb326eaa221d",
"description": "直播创建测试desc",
"orgId": "6d95b35f095f4285b7eebb326eaa221d",
"pid": "fe04ddc7-3628-4740-8db7-a504f3719bf3",
"sessionId": null,
"chatroomId": null,
"hostId": null,
"attendeeId": null,
"platform": 1,
"landscape": 1,
"roomCode": "5mjdFgoMAc6",
"roomName": "直播创建测试",
"sessionName": null,
"status": 1,
"streamStatus": -1,
"type": 1,
"updater": "6d95b35f095f4285b7eebb326eaa221d",
"updateTime": "2017-10-18 09:52:06",
"sourceId": 90,
"appPushProtocal": "https://view.ljlive.cn/apps/play/#/start?roomId=5mjdFgoMAc6",
"appPullProtocal": "https://view.ljlive.cn/apps/play/#/init?roomId=5mjdFgoMAc6",
"appAtPullProtocal": "https://view.ljlive.cn/apps/play/#/init?roomId=5mjdFgoMAc6&at=1",
"isTry": 0,
"userPoint": 0,
"isGuestRoomActive": -1,
"roomCoverUrl": "",
"roomsRelated": null,
"sessions": [
{
"sessionStartTime": "2017-12-19 13:00:00.0",
"sessionEndTime": "2017-12-19 13:20:00.0",
"sessionName": "测试场次2 Update",
"hostName": "",
"hostAvatarUrl": "",
"sessionDesc": "",
"pid": "b306b7f5-c5d7-4736-aeef-079b1dc21c79",
"deletedFlag": 0,
"appPushProtocal": "https://view.ljlive.cn/apps/play/#/start?roomId=b306b7f5-c5d7-4736-aeef-079b1dc21c79",
"appPullProtocal": "https://view.ljlive.cn/apps/play/#/init?roomId=b306b7f5-c5d7-4736-aeef-079b1dc21c79",
"appAtPullProtocal": "https://view.ljlive.cn/apps/play/#/init?roomId=b306b7f5-c5d7-4736-aeef-079b1dc21c79&at=1"
},
{
"sessionStartTime": "2017-12-19 12:00:00.0",
"sessionEndTime": "2017-12-19 12:20:00.0",
"sessionName": "测试场次1",
"hostName": "李灿",
"hostAvatarUrl": "xxxx",
"sessionDesc": "测试场次1 desc",
"pid": "ed2cbf38-147b-444d-aa3c-9c1eea3d57a6",
"deletedFlag": 0,
"appPushProtocal": "https://view.ljlive.cn/apps/play/#/start?roomId=ed2cbf38-147b-444d-aa3c-9c1eea3d57a6",
"appPullProtocal": "https://view.ljlive.cn/apps/play/#/init?roomId=ed2cbf38-147b-444d-aa3c-9c1eea3d57a6",
"appAtPullProtocal": "https://view.ljlive.cn/apps/play/#/init?roomId=ed2cbf38-147b-444d-aa3c-9c1eea3d57a6&at=1"
}
],
"ad": {
"enableAd": 1,
"adImgUrl": "xxxx",
"adLink": "xxxx",
"adLocation": 1,
"pid": "954a7e05-a1f9-4672-9795-784fc1100ad0",
"roomId": "e8983115-f5bb-48a0-b68e-5777d80bd668"
}
}
}
错误时返回:
状态值: HTTP/1.1 400 Bad Request
{
"error": {
"key": "global.noprivilege",
"message": "No privilege."
}
}
错误代码列表:
格式: key=状态码;message
apis.auth.client.status.invalid=400;Client Org status is invalid.
apis.zhibo.orgadmin.validation.service.expired=400;Service is not active.
apis.zhibo.room.validation.roomId.length=400;length of roomId is 11.
apis.zhibo.room.validation.roomId.invalid=400;roomId should be number or charactor.
apis.zhibo.room.validation.roomId.existed=400;roomId is already existed.
apis.zhibo.error.room.streamcreate.error=400;zhibo room stream create failed
apis.zhibo.room.validation.roomname.length=400;Max length of roomName is 100.
apis.zhibo.room.validation.type.invalid=400;room type is invalid.
apis.zhibo.room.validation.guestCount.invalid=400;guestCount is invalid.
apis.zhibo.room.validation.roomNameOfOrg.existed=400;roomName of this org is already existed.
apis.zhibo.room.validation.avatar.length=400;Max length of avatar is 500.
apis.zhibo.room.validation.hostname.length=400;Max length of hostName is 50.
apis.zhibo.room.validation.adImgUrl.length=400;Max length of adImgUrl is 500.
apis.zhibo.room.validation.adLink.length=400;Max length of adLink is 500.
apis.zhibo.room.validation.adLocation.invalid=400;adLocation is invalid.
apis.zhibo.room.validation.enableAd.invalid=400;enableAd is invalid.
apis.zhibo.room.validation.ad.adImgUrl.required=400;ad.adImgUrl is required.
apis.zhibo.room.validation.ad.adLink.required=400;ad.adLink is required.
apis.zhibo.room.validation.ad.userIdNotHost=400;login userId is not the hostId.
apis.zhibo.room.validation.session.sessionName.required=400;session.sessionName is required.
apis.zhibo.room.validation.session.startEndtime.required=400;session.sessionStartTime and session.sessionEndTime are required.
apis.zhibo.room.validation.session.startEndtime.invalid=400;session.sessionStartTime should not equal or greater than session.sessionEndTime.
apis.zhibo.room.validation.session.timeConflict=400;session time period conflict
apis.zhibo.room.validation.session.exceedMaxSize=400;can only create 31 sessions for one room
修改历史
- 2018-02-12 请求body增加字段:roomCoverUrl, sessions[]多场次, ad广告; 返回体
appPushProtocal和appPullProtocal过期(但还能使用),增加sessions对象相关信息及推流url信息,增加广告对象信息; 增加验证信息;