Live/im/api/en

跳转到: 导航, 搜索
(Receive Comments-Callback Mode)
 
(未显示1个用户的10个中间版本)
第1行: 第1行:
  
== 概述 ==
+
== Overview ==
  
  
微博与接入微博的第三方合作的一种模式是“服务端同步”,即微博直播互动系统和第三方互动系统之间做消息同步,从而实现消息共享的效果。发送消息接口和拉取消息接口(主动拉取和回调拉取)提供第三方的消息同步到微博的功能。
+
One of the cooperation mode between weibo and the third-party that access to weibo is server-side synchronization.This mode means doing message synchronization between live interactive system of weibo and interactive system of the third-party to implement message sharing. Send message interface and pull message interface(active pull and callback pull)can synchronize third-party messages to weibo.
  
== 互动上行 ==
+
== Post Comments ==
  
'''说明'''
+
'''Description'''
  
直播用户上行评论接口
+
Post comment of the users to weibo live-im system.
  
  
第17行: 第17行:
  
  
'''支持格式'''
+
'''Support Formats'''
  
 
JSON
 
JSON
第23行: 第23行:
  
  
'''是否需要登录'''
+
'''Authorization'''
  
true 登录授权方式,请参见本WIKI内的 [http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E 如何登录授权]
+
Required. More details of login authorization, Please refer to this WIKI[http://open.weibo.com/wiki/OAuth/en How to login to authorization]
  
  
'''请求参数'''
+
'''Request parameter'''
  
 
{| 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="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段
+
!width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|Parameter field
!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"|Requires
!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"| Field Type
!width="65%" 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"|Field description
{{api_args| access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}}
+
{{api_args| access_token|true|string|Required parameters when using OAuth authorization mode,obtained after OAuth authorization}}
{{api_args|room_id|true|string|房间id}}
+
{{api_args|room_id|true|string|room id}}
{{api_args|ts|true|long|时间戳(1970-01-01 00:00:00 起毫秒数),要求不得延迟2min以上}}
+
{{api_args|ts|true|long|Timestamp(The number of milliseconds from 1970-01-01 00:00:00),cannot delay more than 2min}}
{{api_args|msg_type|true|int|消息类型,参见 [http://open.weibo.com/wiki/Live/im/api#.E6.B6.88.E6.81.AF.E7.B1.BB.E5.9E.8B 消息类型]}}
+
{{api_args|msg_type|true|int|message types, see [http://open.weibo.com/wiki/Live/im/api/en#Message_Type message types]}}
{{api_args|content|true|string|消息内容}}
+
{{api_args|content|true|string|Message content}}
{{api_args|uid|true|long|发送者ID}}
+
{{api_args|uid|true|long|sender ID}}
{{api_args|nickname|true|string|发送者昵称}}
+
{{api_args|nickname|true|string|Sender nickname}}
{{api_args|avatar|true|string|发送者头像url}}
+
{{api_args|avatar|true|string|sender avatar url}}
{{api_args|sign|true|string|对sign之外的其他所有参数进行签名的结果 见[http://open.weibo.com/wiki/Live/im/api#.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 签名算法]}}
+
{{api_args|sign|true|string|The result of signing all the parameters other than sign ,See [http://open.weibo.com/wiki/Live/im/api/en#Signature_Algorithm signature algorithm]}}
{{api_args|extension|false|string|消息扩展字段 [http://open.weibo.com/wiki/Live/im/api#.E6.95.B0.E6.8D.AE.E7.BB.93.E6.9E.84 参见](json object格式,默认为空json object)}}
+
{{api_args|extension|false|string|message extension field [http://open.weibo.com/wiki/Live/im/api/en#Data_Structure see] (json object format, the default is empty json object) }}
{{api_args|offset|false|long|发消息的时间距离直播开始的偏移,单位ms。如果不传,或者传的是负数,做0处理,表示当前消息回放时不展示。}}
+
{{api_args|offset|false|long|the time offset between sending message and the start of the live,unit:ms.If not pass, or pass the negative, do 0 process,indicating that the current message is not displayed when playing back.}}
 
|}
 
|}
  
  
  
'''返回结果'''
+
'''Return result'''
  
//成功返回
+
//Successful return
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
     "error_code":0,    // 0表示成功 其他表示失败。需要看错误消息
+
     "error_code":0,    //0 indicates success,while others mean failed. Need to see the error message
 
     "error_msg":""
 
     "error_msg":""
 
}
 
}
第62行: 第62行:
  
  
//失败返回
+
//Failed to return
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
第70行: 第70行:
 
</pre>
 
</pre>
  
== 互动下行—Pull方式 ==
+
== Receive Comments-Pull Mode ==
'''说明'''
+
'''Description'''
  
该接口提供第三方从微博直播互动系统拉取房间消息的功能。
+
This interface allows the third-party pull room messages from weibo live interactive system.After the third-party initiates the request,the interface will push the latest message in the room continuously as long as the connection is not broken.If the connection is disconnected accidentally,the message will continue to be pushed from the last disconnected position as long as the cumulative number of messages before the reconnection does not exceed the agreed threshold.
第三方发起该请求之后,只要不断开连接,该接口会源源不断的推回房间中最新的消息。如果连接意外断开,只要重连之前累计消息数量不超过商定的阈值,消息都会从上次断开的地方继续推送。
+
  
  
第82行: 第81行:
  
  
'''支持格式'''
+
'''Support Formats'''
  
 
JSON
 
JSON
  
  
'''是否需要登录'''
+
'''Authorization'''
  
true 登录授权方式,请参见本WIKI内的[http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E 如何登录授权]
+
Required. More details of login authorization, Please refer to this WIKI [http://open.weibo.com/wiki/OAuth/en How to log in to authorization]
  
  
'''请求参数'''
+
'''Request parameter'''
 
{| 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="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段
+
!width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|Parameter field
!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"|Requires
!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"|Field Type
!width="65%" 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"|Field description
{{api_args| access_token|true|string|采用OAuth授权方式为必填参数,OAuth授权后获得}}
+
{{api_args| access_token|true|string|Required parameters when using OAuth authorization mode,obtained after OAuth authorization}}
{{api_args|room_id|true|string|房间id}}
+
{{api_args|room_id|true|string|room id}}
 
|}
 
|}
  
'''返回结果'''
+
'''Return Result'''
返回的消息以JSON的方式推送,推送的数据结构如下,每条消息是一个单独的JSON-OBJECT。
+
  
//成功返回
+
The return message is pushed in JSON mode, and the data structure is pushed as follows. Each message is a separate JSON-OBJECT.
 +
 
 +
//Successful return
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
     "error_code":0,    // 0表示成功 其他表示失败。需要看错误消息
+
     "error_code":0,    //0 indicates success,while others mean failed. Need to see the error message
 
     "error_msg":"",
 
     "error_msg":"",
 
}
 
}
 
{
 
{
     // 消息体。见附件[数据结构/消息体]
+
     // message body. See Annex [Data structure / message body]
 
}
 
}
 
{
 
{
     // 消息体
+
     // message body.
 
}
 
}
 
...
 
...
第122行: 第122行:
  
  
//失败返回
+
//Failed to return
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
第130行: 第130行:
 
</pre>
 
</pre>
  
关于错误返回值与错误代码,参见 [http://open.weibo.com/wiki/Live/im/api#.E9.94.99.E8.AF.AF.E7.A0.81.E5.AE.9A.E4.B9.89 错误码定义]
+
about error return values and error codes, see[http://open.weibo.com/wiki/Live/im/api/en#Error_code_definition  Error Code Definitions]
  
== 互动下行—Callback方式 ==
+
== Receive Comments-Callback Mode ==
'''说明'''
+
'''Description'''
  
如果第三方使用的是HTTP Callback的方式接受微博消息,那么第三方也需要提供一个类似[发送消息接口]的接口。要求与那个接口使用相同的参数和返回值。
+
If the third-party uses HTTP Callback mode to accept weibo messages,the third-party needs to provide an interface similar to [send message interface]. Requires the same parameters and return values as that interface.
  
  
 
'''URL'''
 
'''URL'''
  
第三方自定义
+
customize by the third-party
  
  
'''支持格式'''
+
'''Support format'''
  
 
JSON
 
JSON
  
  
'''HTTP请求方式'''
+
'''HTTP request mode'''
  
 
POST
 
POST
  
  
'''是否需要登录'''
+
'''Authorization'''
  
true 登录授权方式,请参见本WIKI内的 [http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E 如何登录授权]
+
Required. More details of login authorization, Please refer to this WIKI[http://open.weibo.com/wiki/OAuth/en How to log in to authorization]
  
  
'''请求参数'''
+
'''Request parameter'''
 
{| 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="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数字段
+
!width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|Parameter field
!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"|Requires
!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"|Field Type
!width="65%" 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"|Field description
{{api_args| source |true|string|申请应用时分配的AppKey,调用接口时候代表应用的唯一身份(采用OAuth授权方式不需要此参数)}}
+
{{api_args| source |true|string|AppKey applied when applying for application,When calling an interface, it represents the unique identity of the application(This parameter is not required when using OAuth authorization mode)}}
{{api_args|room_id|true|string|房间id}}
+
{{api_args|room_id|true|string|room id}}
{{api_args|ts|true|long|时间戳(1970-01-01 00:00:00 起毫秒数)}}
+
{{api_args|ts|true|long|Timestamp(The number of milliseconds from 1970-01-01 00:00:00)}}
{{api_args|msg_type|true|int|消息类型 1 - 评论消息 2 - 点赞消息}}
+
{{api_args|msg_type|true|int|Message Type 1 - Comment Message 2 - Praise message}}
{{api_args|content|true|string|消息内容}}
+
{{api_args|content|true|string|Message content}}
{{api_args|uid|true|long|发送者ID}}
+
{{api_args|uid|true|long|sender ID}}
{{api_args|nickname|true|string|发送者昵称}}
+
{{api_args|nickname|true|string|sender nickname}}
{{api_args|avatar|true|string|发送者头像url}}
+
{{api_args|avatar|true|string|sender avatar url}}
{{api_args|sign|true|string|对sign之外的其他所有参数进行签名的结果 见[http://open.weibo.com/wiki/Live/im/api#.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 签名算法]}}
+
{{api_args|sign|true|string|The result of signing all the parameters other than sign ,See[http://open.weibo.com/wiki/Live/im/api/en#Signature_Algorithm  signature algorithm]}}
{{api_args|extension|false|string|消息扩展字段 [http://open.weibo.com/wiki/Live/im/api#.E6.95.B0.E6.8D.AE.E7.BB.93.E6.9E.84 参见](json object格式,默认为空json object)}}
+
{{api_args|extension|false|string|message extension field[http://open.weibo.com/wiki/Live/im/api/en#Data_Structure see](json object format, the default is empty json object)}}
{{api_args|offset|false|long|发消息的时间距离直播开始的偏移,单位ms。如果不传,或者传的是负数,做0处理,表示当前消息回放时不展示。}}
+
{{api_args|offset|false|long|the time offset between sending message and the start of the live,unit:ms.If not pass, or pass the negative, do 0 process,indicating that the current message is not displayed when playing back.}}
 
|}
 
|}
  
  
返回结果
+
Return result
  
//成功返回
+
//Successful return
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
     "error_code":0,    // 0表示成功 其他表示失败。需要看错误消息
+
     "error_code":0,    //0 indicates success,while others mean failed. Need to see the error message
 
     "error_msg":""
 
     "error_msg":""
 
}
 
}
第190行: 第190行:
  
  
//失败返回
+
//Failed to return
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
第198行: 第198行:
 
</pre>
 
</pre>
  
== 签名算法==
+
== Signature Algorithm==
'''输入:'''
+
'''Input:'''
  
- 键值对列表
+
- the list of key-value pairs
  
- 签名时用的appsecret
+
- appsecret used to signature
  
  
'''输出:'''
+
'''Output:'''
  
签名结果字符串
+
Signature Result String
  
  
'''算法:'''
+
'''Algorithm:'''
  
- 键值对列表的每一项按照key=value的方式组成该项的字符串,各项的字符串按照对应key的字典序排序(key不相同),然后用半角"&"符号连接形成一个字符串。
+
- Each of the key-value pair composes a string follows key=value format,each string is sorted by the dictionary order of the key(key is not the same),then a semiangle sign "&" is used to form a string.
  
- 字符串按照UTF-8编码得到一个字节序列input, secret的字符串按UTF-8编码生成一个字节序列作为key,用hmac-md5的方式计算哈希值的字节序列,哈希值字节序列使用URL-safe-Base64编码,取第6到16个字符作为结果输出。
+
- The string is encoded in UTF-8 to get a byte sequence input,the secret string is encoded by UTF-8 to generate a byte sequence as the key,the byte sequence of the hash value is calculated in the form of hmac-md5,the hash-value byte sequence uses URL-safe-Base64 encoding,then take the 6th to 16th characters as the result output.
  
  
'''算法示例:'''  
+
'''Algorithm Example:'''  
  
  假设输入是:
+
  Assume that the input is:
 
  kv-pair: {"a":"1", "c":"jerry", "b":"tom"}
 
  kv-pair: {"a":"1", "c":"jerry", "b":"tom"}
 
  appsecret:  123456
 
  appsecret:  123456
  
  连接成的字符串就是:
+
  the concatenated string is:
 
  a=1&b=tom&c=jerry
 
  a=1&b=tom&c=jerry
  
 
  hmac-md5("a=1&b=tom&c=jerry",123456)
 
  hmac-md5("a=1&b=tom&c=jerry",123456)
  输出得到字节数组:[-117, -27, -78, -5, 73, 68, -64, -50, 4, 21, 16, -55, -55, -39, -31, -15]
+
  byte array output:[-117, -27, -78, -5, 73, 68, -64, -50, 4, 21, 16, -55, -55, -39, -31, -15]
  
  转成URL-safe的base64字符串:i-Wy-0lEwM4EFRDJydnh8Q==
+
  converted to URL-safe base64 string:i-Wy-0lEwM4EFRDJydnh8Q==
  取6到16位(初始位为0)子串,包含第6位,不包含第16位,共10位:lEwM4EFRDJ
+
  take the 6th to 16th characters(initial bit is 0), contains the 6th, does not contain the 16th, a total of 10 bits:lEwM4EFRDJ
  
  
'''签名结果:'''
+
'''Signature results:'''
  
 
lEwM4EFRDJ
 
lEwM4EFRDJ
  
== 数据结构 ==
+
== Data Structure ==
  
'''消息体'''
+
'''Message Body'''
 
<pre class="brush:js">
 
<pre class="brush:js">
 
{
 
{
     "room_id":string,      // 房间号
+
     "room_id":string,      // room id
     "room_sys_id": uint64, // 房间ID (内部)
+
     "room_sys_id": uint64, // room id (internal)
     "msg_type":int,        // 消息类型,见“消息类型说明”
+
     "msg_type":int,        // Message type, see "Message Type Description"
 
     "mid":long,
 
     "mid":long,
 
     "sender_info":{
 
     "sender_info":{
         // 发送者的用户信息,见“用户信息”
+
         // user information of the sender, see "User Information"
 
     },
 
     },
     "content":string,      // 消息内容
+
     "content":string,      // message content
     "extension":string,    // 消息的扩展字段
+
     "extension":string,    // The extended field of the message
     "offset": long,        // 消息距离视频开始时间间隔,单位ms
+
     "offset": long,        // the offset of message time from the video start time,unit:ms
     "created_at":long     // 时间戳,距离1970-01-01 0:00:00 GMT的毫秒数
+
     "created_at":long   // Timestamp,the number of milliseconds from 1970-01-01 0:00:00 GMT
    // 如果还有其他字段,这些字段在此处继续,相关字段见“各消息类型的额外字段”
+
      //If there are other fields, these fields continue here,related fields See "Additional fields for each message type"
 
}
 
}
  
第261行: 第261行:
 
'''extension'''
 
'''extension'''
  
消息类型1~14时,各类消息会有一些该类型特有的字段用于表示一些业务,这些字段会出现在extension中的sys字段里面,结构如下:
+
For the message types 1 to 14, each kind of message will have some unique fields used to represent the business, these fields will appear in the sys field inside of the extension, the structure is as follows:
 
<pre class="brush:js">
 
<pre class="brush:js">
 
extension = {
 
extension = {
 
     "sys": {
 
     "sys": {
         // 此处出现的字段,见”各类型特有的额外字段“。如果额外字段列表为空,那么"sys"字段可以不存在。
+
         // The fields that appear here are listed in "unique additional fields to each type".If the extra field list is empty, the "sys" field may not exist
 
     },
 
     },
     // "其它透传的字段"
+
     // "Other transparent fields"
 
}
 
}
 
</pre>
 
</pre>
  
各类型特有的额外字段
+
unique additional fields to each type
  
 
<pre class="brush:js">
 
<pre class="brush:js">
聊天消息,msg_type=1
+
chat message,msg_type=1
"msg_behavior":uint32  //消息的显示行为 0:默认 1.弹幕
+
"msg_behavior":uint32  //the display behavior of message 0: Default 1. Barrage
+
 
点赞消息,msg_type=2
+
praise message,msg_type=2
"praises_count":int    // 当前总赞数
+
"praises_count":int    // Current total number of praise
"inc_praises":long    // 用户点赞次数
+
"inc_praises":long    // the number of times that users point like
+
 
禁言,msg_type=4
+
banned,msg_type=4
"shut_info":{          // 被禁言的用户信息
+
"shut_info":{          // the users be banned
     "shutted_until":uint32  //禁言结束的剩余时间,单位s
+
     "shutted_until":uint32  //the remaining time of the end of prohibition,unit:s
     "members":[              //被禁言用户列表
+
     "members":[              //User list that be banned
 
     {
 
     {
       "uid":uint64          //被禁言用户的UID
+
       "uid":uint64          //the UID of the user that be banned
       "user_system":string  //被禁言用户所属系统
+
       "user_system":string  //the system that the banned user belongs to
 
     }
 
     }
 
   ]
 
   ]
 
}
 
}
+
 
房间变更,msg_type=11
+
room change,msg_type=11
"live_status":int      // 表示直播的状态
+
"live_status":int      // Indicates the status of the live broadcast
 
"room_info": {
 
"room_info": {
     // 房间信息体,见“房间信息”
+
     // Room information body, see "room information"
 
}
 
}
+
 
加退房间,msg_type=12
+
join room and exit room,msg_type=12
"exit_or_enter_room":int  // 0:退出 1:进入
+
"exit_or_enter_room":int  // 0:exit 1:join
 
"room_info": {
 
"room_info": {
     // 房间信息体,见“房间信息”
+
     // Room information body, see "room information"
 
}
 
}
+
 
增加删除管理员,msg_type=14
+
add and delete administrator,msg_type=14
"admin_info":{            // 被增加或删除的用户信息
+
"admin_info":{            // information of users that be added or deleted
     "uid":uint64              //管理员的UID
+
     "uid":uint64              //UID of the administrator
     "user_system":string      //管理员所属系统
+
     "user_system":string      //the system that the administrator belongs to
     "type":int              //操作类型 1 增加 2 删除
+
     "type":int              //Operation Type 1:Add 2:Delete
 
}
 
}
 
</pre>
 
</pre>
  
== 直播接口 ==
+
== Live Interface ==
请参考[http://open.weibo.com/wiki/Live/api 直播接口文档]
+
Please refer to[http://open.weibo.com/wiki/Live/api/en live interface documentation]
  
== 消息类型 ==
+
== Message Type ==
  
     1 - 聊天消息
+
     1 - chat message
     2 - 赞消息
+
     2 - praise message
     3 - 点亮主播消息
+
     3 - light the anchor message
     4 - 禁言消息
+
     4 - banned message
     6 - 公告消息
+
     6 - announcement message
     7 - 分享直播消息
+
     7 - share live messages
     8 - 关注主播消息
+
     8 - focus on the anchor message
     11 - 直播变更消息(房间的任何状态变更都会进行push)
+
     11 -live change message (any change in room status will be pushed)
     12 - 加入/退出房间消息
+
     12 - join / exit room message
     13 - 打赏消息
+
     13 - reward message
     14 - 管理员变更消息
+
     14 - administrator change message
     100 - 自定义消息类型
+
     100 - customize message type
  
== 错误码定义 ==
+
== Error code definition ==
 
<table class="wiki_table">
 
<table class="wiki_table">
 
<tr>
 
<tr>
<th style="width: 10%">错误码</th>
+
<th style="width: 10%">error code</th>
<th>错误说明</th>
+
<th>error description</th>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9101</td>
 
<td>9101</td>
<td>认证失败</td>
+
<td>authentication failed</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9102</td>
 
<td>9102</td>
<td>内部错误</td>
+
<td>internal error</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9103</td>
 
<td>9103</td>
<td>数据格式错误</td>
+
<td>data format error</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9104</td>
 
<td>9104</td>
<td>消息内容包含垃圾信息</td>
+
<td>the message contains spam</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9105</td>
 
<td>9105</td>
<td>已经存在</td>
+
<td>already exists</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9106</td>
 
<td>9106</td>
<td>数据不合法。与9103不同的地方在于:9103是数据格式错误, 比如int型的参数传了一个无法解析成int的字符串。而当前错误码表示数据格式本身没有问题, 但是是一个不合法的数据, 比如ID对应的实体不存在</td>
+
<td>data is not legal.the point that unlike 9103 : 9103 is the data format error, such as a int parameter should be passed but passed a string can not be resolved into int. And the current error code indicates that the data format itself is not a problem, but is an illegal data, such as ID corresponding entity does not exist.</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9107</td>
 
<td>9107</td>
<td>房间不允许发言</td>
+
<td>room is not allowed to speak</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9108</td>
 
<td>9108</td>
<td>用户不存在</td>
+
<td>user does not exist</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9109</td>
 
<td>9109</td>
<td>房间不存在</td>
+
<td>room does not exist</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9110</td>
 
<td>9110</td>
<td>token解析错误</td>
+
<td>token parse error</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9111</td>
 
<td>9111</td>
<td>房间状态不正确</td>
+
<td>room status is not correct</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9112</td>
 
<td>9112</td>
<td>用户被禁言</td>
+
<td>the user is banned</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>9113</td>
 
<td>9113</td>
<td>当前操作不允许</td>
+
<td>the current operation is not allowed</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
 
<td>1019</td>
 
<td>1019</td>
<td>当前操作不支持</td>
+
<td>the current operation is not supported</td>
 
</tr>
 
</tr>
 
</table>
 
</table>

2017年2月24日 (五) 16:59的最后版本

目录

Overview

One of the cooperation mode between weibo and the third-party that access to weibo is server-side synchronization.This mode means doing message synchronization between live interactive system of weibo and interactive system of the third-party to implement message sharing. Send message interface and pull message interface(active pull and callback pull)can synchronize third-party messages to weibo.

Post Comments

Description

Post comment of the users to weibo live-im system.


URL

https://api.weibo.com/2/liveim/message/sync.json [POST]


Support Formats

JSON


Authorization

Required. More details of login authorization, Please refer to this WIKIHow to login to authorization


Request parameter

Parameter field Requires Field Type Field description
access_token true string Required parameters when using OAuth authorization mode,obtained after OAuth authorization
room_id true string room id
ts true long Timestamp(The number of milliseconds from 1970-01-01 00:00:00),cannot delay more than 2min
msg_type true int message types, see message types
content true string Message content
uid true long sender ID
nickname true string Sender nickname
avatar true string sender avatar url
sign true string The result of signing all the parameters other than sign ,See signature algorithm
extension false string message extension field see (json object format, the default is empty json object)
offset false long the time offset between sending message and the start of the live,unit:ms.If not pass, or pass the negative, do 0 process,indicating that the current message is not displayed when playing back.


Return result

//Successful return

{
    "error_code":0,    //0 indicates success,while others mean failed. Need to see the error message
    "error_msg":""
}


//Failed to return

{
    "error_code": 91XX,
    "error_msg": "xxxxxxxxx"
}

Receive Comments-Pull Mode

Description

This interface allows the third-party pull room messages from weibo live interactive system.After the third-party initiates the request,the interface will push the latest message in the room continuously as long as the connection is not broken.If the connection is disconnected accidentally,the message will continue to be pushed from the last disconnected position as long as the cumulative number of messages before the reconnection does not exceed the agreed threshold.


URL

https://api.weibo.com/2/liveim/message/pull.stream [GET]


Support Formats

JSON


Authorization

Required. More details of login authorization, Please refer to this WIKI How to log in to authorization


Request parameter

Parameter field Requires Field Type Field description
access_token true string Required parameters when using OAuth authorization mode,obtained after OAuth authorization
room_id true string room id

Return Result

The return message is pushed in JSON mode, and the data structure is pushed as follows. Each message is a separate JSON-OBJECT.

//Successful return

{
    "error_code":0,    //0 indicates success,while others mean failed. Need to see the error message
    "error_msg":"",
}
{
    // message body. See Annex [Data structure / message body]
}
{
    // message body.
}
...


//Failed to return

{
    "error_code": 91XX,
    "error_msg": "xxxxxxxxx"
}

about error return values and error codes, seeError Code Definitions

Receive Comments-Callback Mode

Description

If the third-party uses HTTP Callback mode to accept weibo messages,the third-party needs to provide an interface similar to [send message interface]. Requires the same parameters and return values as that interface.


URL

customize by the third-party


Support format

JSON


HTTP request mode

POST


Authorization

Required. More details of login authorization, Please refer to this WIKIHow to log in to authorization


Request parameter

Parameter field Requires Field Type Field description
source true string AppKey applied when applying for application,When calling an interface, it represents the unique identity of the application(This parameter is not required when using OAuth authorization mode)
room_id true string room id
ts true long Timestamp(The number of milliseconds from 1970-01-01 00:00:00)
msg_type true int Message Type 1 - Comment Message 2 - Praise message
content true string Message content
uid true long sender ID
nickname true string sender nickname
avatar true string sender avatar url
sign true string The result of signing all the parameters other than sign ,Seesignature algorithm
extension false string message extension fieldsee(json object format, the default is empty json object)
offset false long the time offset between sending message and the start of the live,unit:ms.If not pass, or pass the negative, do 0 process,indicating that the current message is not displayed when playing back.


Return result

//Successful return

{
    "error_code":0,    //0 indicates success,while others mean failed. Need to see the error message
    "error_msg":""
}


//Failed to return

{
    "error_code": 91XX,
    "error_msg": "xxxxxxxxx"
}

Signature Algorithm

Input:

- the list of key-value pairs

- appsecret used to signature


Output:

Signature Result String


Algorithm:

- Each of the key-value pair composes a string follows key=value format,each string is sorted by the dictionary order of the key(key is not the same),then a semiangle sign "&" is used to form a string.

- The string is encoded in UTF-8 to get a byte sequence input,the secret string is encoded by UTF-8 to generate a byte sequence as the key,the byte sequence of the hash value is calculated in the form of hmac-md5,the hash-value byte sequence uses URL-safe-Base64 encoding,then take the 6th to 16th characters as the result output.


Algorithm Example:

Assume that the input is:
kv-pair: {"a":"1", "c":"jerry", "b":"tom"}
appsecret:  123456
the concatenated string is:
a=1&b=tom&c=jerry
hmac-md5("a=1&b=tom&c=jerry",123456)
byte array output:[-117, -27, -78, -5, 73, 68, -64, -50, 4, 21, 16, -55, -55, -39, -31, -15]
converted to URL-safe base64 string:i-Wy-0lEwM4EFRDJydnh8Q==
take the 6th to 16th characters(initial bit is 0), contains the 6th, does not contain the 16th, a total of 10 bits:lEwM4EFRDJ


Signature results:

lEwM4EFRDJ

Data Structure

Message Body

{
    "room_id":string,      // room id
    "room_sys_id": uint64, // room id (internal)
    "msg_type":int,        // Message type, see "Message Type Description"
    "mid":long,
    "sender_info":{
        // user information of the sender, see "User Information"
    },
    "content":string,      // message content
    "extension":string,    // The extended field of the message
    "offset": long,        // the offset of message time from the video start time,unit:ms
    "created_at":long   // Timestamp,the number of milliseconds from 1970-01-01 0:00:00 GMT
      //If there are other fields, these fields continue here,related fields See "Additional fields for each message type"
}

extension

For the message types 1 to 14, each kind of message will have some unique fields used to represent the business, these fields will appear in the sys field inside of the extension, the structure is as follows:

extension = {
    "sys": {
        // The fields that appear here are listed in "unique additional fields to each type".If the extra field list is empty, the "sys" field may not exist 
    },
    // "Other transparent fields"
}

unique additional fields to each type

chat message,msg_type=1
"msg_behavior":uint32  //the display behavior of message  0: Default 1. Barrage
  
praise message,msg_type=2
"praises_count":int    // Current total number of praise
"inc_praises":long     // the number of times that users point like 
  
banned,msg_type=4
"shut_info":{          // the users be banned
    "shutted_until":uint32  //the remaining time of the end of prohibition,unit:s
    "members":[              //User list that be banned
     {
       "uid":uint64          //the UID of the user that be banned
       "user_system":string  //the system that the banned user belongs to 
     }
   ]
}
  
room change,msg_type=11
"live_status":int      // Indicates the status of the live broadcast
"room_info": {
    // Room information body, see "room information"
}
  
join room and exit room,msg_type=12
"exit_or_enter_room":int  // 0:exit 1:join
"room_info": {
    // Room information body, see "room information"
}
  
add and delete administrator,msg_type=14
"admin_info":{            // information of users that be added or deleted
    "uid":uint64              //UID of the administrator
    "user_system":string      //the system that the administrator belongs to 
    "type":int               //Operation Type 1:Add 2:Delete
}

Live Interface

Please refer tolive interface documentation

Message Type

   1 - chat message
   2 - praise message
   3 - light the anchor message
   4 - banned message
   6 - announcement message
   7 - share live messages
   8 - focus on the anchor message
   11 -live change message (any change in room status will be pushed)
   12 - join / exit room message
   13 - reward message
   14 - administrator change message
   100 - customize message type

Error code definition

error code error description
9101 authentication failed
9102 internal error
9103 data format error
9104 the message contains spam
9105 already exists
9106 data is not legal.the point that unlike 9103 : 9103 is the data format error, such as a int parameter should be passed but passed a string can not be resolved into int. And the current error code indicates that the data format itself is not a problem, but is an illegal data, such as ID corresponding entity does not exist.
9107 room is not allowed to speak
9108 user does not exist
9109 room does not exist
9110 token parse error
9111 room status is not correct
9112 the user is banned
9113 the current operation is not allowed
1019 the current operation is not supported
文档更新时间: 2017-02-24