推送直播间消息
更新时间不可用
向直播间推送礼物、评论和点赞消息。
https://{domain}/v2/projects/{appid}/bullet-game/api/live-data/games/{gameid}/rooms/${roomid}/msgType/{msg_type}:push注意
- 调用频率限制:单个直播间调用上限为 200 次/秒。
- 建议平台侧对单个用户做消息聚合,以减小请求数。
- 当 QPS 达到容量后建议在服务端做退避策略,例如第一次等待 3 秒,第二次等待 6 秒。
gameidstring游戏编号,调用获取云游戏列表获得。
roomidstring房间编号,以 appid 作为前缀的全局唯一房间 ID。
msg_typestring消息类型,支持以下三种:
live_gift:礼物消息。live_comment:评论消息。live_like:点赞消息。
Authorizationstring发送 HTTP 请求时,你需要将用于游戏推流使用的 RTC Token 填入 HTTP 请求头部的 Authorization 字段。Token 生成方式请参考使用 Token 鉴权。
Content-Typestring数据类型,必须包含 application/json。
根据推送的消息类型不同,请求包体中的 payload 字段内容也有所不同。
注意
- 支持单次调用提交多个与路径参数中的
msg_type类型一致的payload。 - 三种消息类型的
payload字段名均为payload,参数说明中的中文仅作区分用,实际调用时需要删除。
msg_idstring全局唯一的消息 ID,以 APP ID 为前缀。
openidstring主播编号。以 appid 作为前缀的全局唯一主播 ID。
gift_idnumber礼物 ID,需按约定的礼物编号发送。
gift_numinteger送出的礼物数量。
gift_valueinteger礼物的价值,折算成分。
avatar_urlstring主播头像 URL 地址,会显示在游戏中。
nicknamestring主播昵称,会显示在游戏中。
timestampnumber消息推送时刻的毫秒级时间戳。误差须小于 60 秒,否则即使推送成功业务侧也无响应。
msg_idstring全局唯一的消息 ID,以 APP ID 为前缀。
openidstring主播编号。以 appid 作为前缀的全局唯一主播 ID。
contentstring评论内容。
avatar_urlstring主播头像 URL 地址,会显示在游戏中。
nicknamestring主播昵称,会显示在游戏中。
timestampnumber消息推送时刻的毫秒级时间戳。误差须小于 60 秒,否则即使推送成功业务侧也无响应。
msg_idstring全局唯一的消息 ID,以 APP ID 为前缀。
openidstring主播编号。以 appid 作为前缀的全局唯一主播 ID。
like_numinteger点赞数量,上游每 2 秒合并一次数据。
avatar_urlstring主播头像 URL 地址,会显示在游戏中。
nicknamestring主播昵称,会显示在游戏中。
timestampnumber消息推送时刻的毫秒级时间戳。误差须小于 60 秒,否则即使推送成功业务侧也无响应。
响应
OK
响应 Body
err_nointeger请求错误码,0 表示请求成功,非 0 表示请求失败,对应的错误原因和解决方案详见响应状态码。
err_msgstringerr_no 为非 0 时附带的错误提示信息。
logidstring请求链路 id, 用于出现未知问题时提供给声网技术支持以便定位问题。
dataobject请求成功时返回空对象。
请求示例
curl --request POST \
--url "https://:domain/v2/projects/:appid/bullet-game/api/live-data/games/:gameid/rooms/\$:roomid/msgType/:msg_type:push" \
--header 'Authorization: <string>' \
-H 'Content-Type: application/json' \
-d '[
{
"礼物-payload": {
"msg_id": "abcxxxxxxxxx321_12345678",
"openid": "abcxxxxxxxxx321_testopenid",
"gift_id": 10001,
"gift_num": 10,
"gift_value": 10000,
"avatar_url": "http://127.0.0.1/xxxxx.jpg",
"nickname": "Player",
"timestamp": 1699068964
},
"评论-payload": {
"msg_id": "abcxxxxxxxxx321_12345678",
"openid": "abcxxxxxxxxx321_testopenid",
"content": "string",
"avatar_url": "http://127.0.0.1/xxxxx.jpg",
"nickname": "Player",
"timestamp": 1699068964
},
"点赞-payload": {
"msg_id": "abcxxxxxxxxx321_12345678",
"openid": "abcxxxxxxxxx321_testopenid",
"like_num": 123,
"avatar_url": "http://127.0.0.1/xxxxx.jpg",
"nickname": "Player",
"timestamp": 1699068964
}
}
]'响应示例
{
"err_no": 0,
"err_msg": "success",
"logid": "1690000000352",
"data": {}
}