Live/api
第28行: | 第28行: | ||
返回: | 返回: | ||
− | |||
{| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | ||
|- | |- | ||
− | !width=" | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
!width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 | ||
− | !width=" | + | !width="75%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 |
{{api_args|id|string|直播ID}} | {{api_args|id|string|直播ID}} | ||
{{api_args|rtmp_url|string|直播推流地址}} | {{api_args|rtmp_url|string|直播推流地址}} | ||
|} | |} | ||
− | + | ||
+ | |||
示例: | 示例: | ||
第59行: | 第59行: | ||
参数: | 参数: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | --- | + | |- |
− | access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得 | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
− | id|true|string|直播ID | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 |
− | title|false|string|直播描述 | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型 |
− | summary|false|string|微博文本内容,必须做URLencode,内容不超过130个汉字 | + | !width="65%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 |
− | + | {{api_args|access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}} | |
− | + | {{api_args|id|true|string|直播ID}} | |
− | stop|false|string|直播结束,0:直播中,1:直播结束,默认为0 | + | {{api_args|title|false|string|直播描述}} |
− | replay_url|false|string|直播回放地址 | + | {{api_args|summary|false|string|微博文本内容,必须做URLencode,内容不超过130个汉字}} |
+ | {{api_args|published|false|string|微博是否发布,0:公开发布,1:仅自己可见,默认为2}} | ||
+ | {{api_args|image|false|string|直播封面图地址}} | ||
+ | {{api_args|stop|false|string|直播结束,0:直播中,1:直播结束,默认为0}} | ||
+ | {{api_args|replay_url|false|string|直播回放地址}} | ||
+ | |} | ||
返回: | 返回: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | + | |- | |
− | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 | |
+ | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 | ||
+ | !width="75%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | ||
+ | {{api_args|id|string|直播ID}} | ||
+ | |} | ||
示例: | 示例: | ||
− | + | <pre> | |
{ | { | ||
id : | id : | ||
} | } | ||
− | + | </pre> | |
==直播删除接口== | ==直播删除接口== | ||
第91行: | 第100行: | ||
参数: | 参数: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | --- | + | |- |
− | access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得 | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
− | id|true|string|直播ID| | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 |
+ | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型 | ||
+ | !width="65%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | ||
+ | {{api_args|access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}} | ||
+ | {{api_args|id|true|string|直播ID}} | ||
+ | |} | ||
返回: | 返回: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | + | |- | |
− | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 | |
− | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 | |
+ | !width="75%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | ||
+ | {{api_args|id|string|直播ID}} | ||
+ | |} | ||
+ | |||
示例: | 示例: | ||
− | + | <pre> | |
{ | { | ||
id : | id : | ||
} | } | ||
− | + | </pre> | |
==直播信息接口== | ==直播信息接口== | ||
第117行: | 第135行: | ||
参数: | 参数: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | --- | + | |- |
− | access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得 | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
− | id|true|string|直播ID | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 |
− | detail|false|string|直播详情,0:不返回,1:返回,默认为0 | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型 |
+ | !width="65%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | ||
+ | {{api_args|access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}} | ||
+ | {{api_args|id|true|string|直播ID}} | ||
+ | {{api_args|detail|false|string|直播详情,0:不返回,1:返回,默认为0}} | ||
+ | |} | ||
+ | |||
返回: | 返回: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | + | |- | |
− | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 | |
− | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 | |
− | + | !width="75%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | |
− | + | {{api_args|id|string|直播ID}} | |
− | + | {{api_args|uid|string|直播作者ID}} | |
− | + | {{api_args|title|string|直播标题}} | |
− | + | {{api_args|summary|string|微博文本内容}} | |
− | + | {{api_args|image|string|封面图地址}} | |
− | + | {{api_args|url|string|直播落地页}} | |
− | + | {{api_args|status|int|直播状态}} | |
− | + | {{api_args|create_time|string|直播创建时间}} | |
+ | {{api_args|live_views|int|直播实时在线人数,detail为1时返回}} | ||
+ | {{api_args|total_views|int|直播总在线人数,detail为1时返回}} | ||
+ | {{api_args|total_stars|int|直播总点赞数,detail为1时返回}} | ||
+ | |} | ||
示例: | 示例: | ||
− | + | </pre> | |
{ | { | ||
id : | id : | ||
第154行: | 第182行: | ||
create_time : | create_time : | ||
} | } | ||
− | + | </pre> | |
== 直播互动接口== | == 直播互动接口== | ||
第164行: | 第192行: | ||
参数: | 参数: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | ----|--- | + | |- |
− | access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得 | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
− | id|true|string|直播ID | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 |
− | type| | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型 |
− | content|true|string|评论文本内容| | + | !width="65%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 |
+ | {{api_args|access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}} | ||
+ | {{api_args|id|true|string|直播ID}} | ||
+ | {{api_args|type|true|int|评论类型,现在只有文本,默认为0}} | ||
+ | {{api_args|content|true|string|评论文本内容}} | ||
+ | |} | ||
返回: | 返回: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | ---|---|---| | + | |- |
− | id|string|直播ID | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
− | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 | |
+ | !width="75%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | ||
+ | {{api_args|id|string|直播ID}} | ||
+ | |} | ||
示例: | 示例: | ||
− | + | <pre> | |
{ | { | ||
id : | id : | ||
context : | context : | ||
} | } | ||
− | + | </pre> | |
==下行互动== | ==下行互动== | ||
第194行: | 第230行: | ||
参数: | 参数: | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | --- | + | |- |
− | access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得 | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段 |
− | id|true|string| | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段必选 |
+ | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型 | ||
+ | !width="65%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 | ||
+ | {{api_args|access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}} | ||
+ | {{api_args|id|true|string|直播ID}} | ||
+ | |} | ||
+ | |||
返回示例: | 返回示例: | ||
− | + | <pre> | |
[ | [ | ||
[MsgHeader,MsgBody], | [MsgHeader,MsgBody], | ||
第207行: | 第249行: | ||
...... | ...... | ||
] | ] | ||
− | + | </pre> | |
− | + | <pre> | |
MsgHeader = { | MsgHeader = { | ||
type: "chatroom", | type: "chatroom", | ||
第230行: | 第272行: | ||
} | } | ||
} | } | ||
− | + | </pre> | |
− | + | <pre> | |
NoticesHeader = { | NoticesHeader = { | ||
type: "chatroom", | type: "chatroom", | ||
第254行: | 第296行: | ||
type(通知类型): | type(通知类型): | ||
4:点赞数量,users为空,value为点赞数量,uint32 | 4:点赞数量,users为空,value为点赞数量,uint32 | ||
− | + | </pre> | |
− | + | ==错误代码== | |
错误码 | 错误码 | ||
− | + | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color:#CCCCCC;" | |
− | --- | + | |- |
− | 20001|live create error|创建直播失败 | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|错误码 |
− | 20002|update weibo error|发微博失败 | + | !width="10%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|错误msg |
− | 20003|post param loss|post参数缺失 | + | !width="75%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|描述 |
− | 20004|get param loss|get参数缺失 | + | {{api_args|20001|live create error|创建直播失败}} |
− | 20005|live delete error|删除直播失败 | + | {{api_args|20002|update weibo error|发微博失败}} |
− | 20006|live update error|更新直播失败 | + | {{api_args|20003|post param loss|post参数缺失}} |
− | 20007|send message error|评论失败 | + | {{api_args|20004|get param loss|get参数缺失}} |
− | 20008|rsync message error|拉取失败 | + | {{api_args|20005|live delete error|删除直播失败}} |
− | 20009|live id unexist|直播ID不存在| | + | {{api_args|20006|live update error|更新直播失败}} |
− | 20010|weibo content more than 130 word|微博文字超过130字了 | + | {{api_args|20007|send message error|评论失败}} |
− | 20011|msg content more than 100 word,or is null|评论文字超过100字了,或者为空 | + | {{api_args|20008|rsync message error|拉取失败}} |
− | 20012|msg content type error|发言的文本类型错误 | + | {{api_args|20009|live id unexist|直播ID不存在}} |
− | 20013|authority not allow|权限不够(appkey or uid不一致)| | + | {{api_args|20010|weibo content more than 130 word|微博文字超过130字了}} |
+ | {{api_args|20011|msg content more than 100 word,or is null|评论文字超过100字了,或者为空}} | ||
+ | {{api_args|20012|msg content type error|发言的文本类型错误}} | ||
+ | {{api_args|20013|authority not allow|权限不够(appkey or uid不一致)}} | ||
+ | |} | ||
示例: | 示例: | ||
− | + | <pre> | |
{ | { | ||
request : | request : | ||
第283行: | 第329行: | ||
error : | error : | ||
} | } | ||
− | + | </pre> |
2016年6月2日 (四) 15:25的版本
目录 |
直播服务OPEN API V1.0
直播接口授权机制
目前微博开放平台用户身份鉴权采用的是Oauth2.0,参见如何登录授权
直播创建接口
URL : https://api.weibo.com/2/proxy/live/create [POST]
说明:新建直播对象,获取直播推流地址,并同时发微博
参数:
参数字段 | 字段必选 | 字段类型 | 字段说明 |
---|---|---|---|
access_token | true | string | 采用OAuth授权方式为必填参数,OAuth授权后获得 |
title | true | string | 直播描述 |
width | true | string | 直播宽度 |
height | true | string | 直播高度 |
summary | false | string | 微博文本内容,必须做URLencode,内容不超过130个汉字 |
published | false | string | 微博是否发布,0:公开发布,1:仅自己可见,默认为0 |
image | false | string | 封面图地址,注意封面图的宽高和直播的宽高比例要一致 |
replay | false | string | 是否录制,0:不录制,1:录制,默认为1 |
返回:
参数字段 | 字段必选 | 字段说明 | |
---|---|---|---|
id | string | 直播ID | {{{4}}} |
rtmp_url | string | 直播推流地址 | {{{4}}} |
示例:
{ id : 直播ID rtmp_url : 直播推流地址 }
直播推流
第三方根据直播创建接口返回的推流地址rtmp_url开始推流
直播更新接口
URL : https://api.weibo.com/2/proxy/live/update [POST]
说明:直播对象信息、状态等更新
参数:
参数字段 | 字段必选 | 字段类型 | 字段说明 |
---|---|---|---|
access_token | true | string | 采用OAuth授权方式为必填参数,OAuth授权后获得 |
id | true | string | 直播ID |
title | false | string | 直播描述 |
summary | false | string | 微博文本内容,必须做URLencode,内容不超过130个汉字 |
published | false | string | 微博是否发布,0:公开发布,1:仅自己可见,默认为2 |
image | false | string | 直播封面图地址 |
stop | false | string | 直播结束,0:直播中,1:直播结束,默认为0 |
replay_url | false | string | 直播回放地址 |
返回:
参数字段 | 字段必选 | 字段说明 | |
---|---|---|---|
id | string | 直播ID | {{{4}}} |
示例:
{ id : }
直播删除接口
URL : https://api.weibo.com/2/proxy/live/delete [POST]
说明:直播对象删除,不可逆
参数:
参数字段 | 字段必选 | 字段类型 | 字段说明 |
---|---|---|---|
access_token | true | string | 采用OAuth授权方式为必填参数,OAuth授权后获得 |
id | true | string | 直播ID |
返回:
参数字段 | 字段必选 | 字段说明 | |
---|---|---|---|
id | string | 直播ID | {{{4}}} |
示例:
{ id : }
直播信息接口
URL : https://api.weibo.com/2/proxy/live/show [POST]
说明:直播对象信息、互动信息等获取
参数:
参数字段 | 字段必选 | 字段类型 | 字段说明 |
---|---|---|---|
access_token | true | string | 采用OAuth授权方式为必填参数,OAuth授权后获得 |
id | true | string | 直播ID |
detail | false | string | 直播详情,0:不返回,1:返回,默认为0 |
返回:
参数字段 | 字段必选 | 字段说明 | |
---|---|---|---|
id | string | 直播ID | {{{4}}} |
uid | string | 直播作者ID | {{{4}}} |
title | string | 直播标题 | {{{4}}} |
summary | string | 微博文本内容 | {{{4}}} |
image | string | 封面图地址 | {{{4}}} |
url | string | 直播落地页 | {{{4}}} |
status | int | 直播状态 | {{{4}}} |
create_time | string | 直播创建时间 | {{{4}}} |
live_views | int | 直播实时在线人数,detail为1时返回 | {{{4}}} |
total_views | int | 直播总在线人数,detail为1时返回 | {{{4}}} |
total_stars | int | 直播总点赞数,detail为1时返回 | {{{4}}} |
示例:
</pre> { id : uid : title : url : summary : image : status : live_views : total_views : create_time : } </pre>
直播互动接口
- 上行互动
URL : https://api.weibo.com/2/proxy/live/chatroom/r_msg [POST]
说明:直播用户上行评论接口
参数:
参数字段 | 字段必选 | 字段类型 | 字段说明 |
---|---|---|---|
access_token | true | string | 采用OAuth授权方式为必填参数,OAuth授权后获得 |
id | true | string | 直播ID |
type | true | int | 评论类型,现在只有文本,默认为0 |
content | true | string | 评论文本内容 |
返回:
参数字段 | 字段必选 | 字段说明 | |
---|---|---|---|
id | string | 直播ID | {{{4}}} |
示例:
{ id : context : }
下行互动
URL : https://api.weibo.com/2/proxy/live/chatroom/r_sync [POST]
说明:直播者获取下行互动接口
参数:
参数字段 | 字段必选 | 字段类型 | 字段说明 |
---|---|---|---|
access_token | true | string | 采用OAuth授权方式为必填参数,OAuth授权后获得 |
id | true | string | 直播ID |
返回示例:
[ [MsgHeader,MsgBody], [NoticesHeader,NoticesBody], ...... ]
MsgHeader = { type: "chatroom", proto: "r_msg", ...... } MsgBody = #r_msg: { "id": "uint64", //下行时为消息的global id "from": "uint64", //下行时为发送者的id "to": "string", //互动id "type": "uint32", "content": "string", "latitude": "string", "longitude": "string", "curr_play": "uint64", //记录直播直播进度,精确到毫秒;-1:未开始;0:直播已结束 "additional_desc": "string", "user":{ "id": "uint64", //uid "name": "string", //昵称 "avatar": "string" //头像信息 } }
NoticesHeader = { type: "chatroom", proto: "r_notices", ...... } NoticesBody = #r_notices: { "id": "string", //房间对应的room id "error_msg": "string", //只有出错的时候才会提供此选项 "notices": [{ //多个通知列表 "type": "uint32", "users":[{ //同一种类型事件通知,可以为空,可以是单个用户,或多个用户等。 "id": "uint64", "name": "string", "avatar": "string" }], "value": "uint32", //其值类型由type确定,可以为空 "time": "uint64" }] } 注: type(通知类型): 4:点赞数量,users为空,value为点赞数量,uint32
错误代码
错误码
错误码 | 错误msg | 描述 | |
---|---|---|---|
20001 | live create error | 创建直播失败 | {{{4}}} |
20002 | update weibo error | 发微博失败 | {{{4}}} |
20003 | post param loss | post参数缺失 | {{{4}}} |
20004 | get param loss | get参数缺失 | {{{4}}} |
20005 | live delete error | 删除直播失败 | {{{4}}} |
20006 | live update error | 更新直播失败 | {{{4}}} |
20007 | send message error | 评论失败 | {{{4}}} |
20008 | rsync message error | 拉取失败 | {{{4}}} |
20009 | live id unexist | 直播ID不存在 | {{{4}}} |
20010 | weibo content more than 130 word | 微博文字超过130字了 | {{{4}}} |
20011 | msg content more than 100 word,or is null | 评论文字超过100字了,或者为空 | {{{4}}} |
20012 | msg content type error | 发言的文本类型错误 | {{{4}}} |
20013 | authority not allow | 权限不够(appkey or uid不一致) | {{{4}}} |
示例:
{ request : error_code : error : }