Broadcast Message by User ID
Updated: 2025-06-30 10:38:42
API Description
根据用户ID列表向指定频道内的用户广播消息
接口支持https协议
API URL
https://api.polyv.net/live/v5/chat/redirect/channel/emit-by-userId/post
Request Method
POST
API Constraints
- The API supports both HTTP and HTTPS; HTTPS is recommended for security.
- The
userIdslist cannot be empty. - The
userIdslist length cannot exceed 2000. - Rate limiting is enforced; error messages will be returned if the system is busy.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId [See details in Get Secret Key] |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid within 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used for generating the signature is critical for communication data security. It must never be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server and obtain response data. [See details in Signature Generation Rules] |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| roomId | true | String(1, 100) | Channel ID |
| userIds | true | Array(String(1, 2000)) | List of user IDs |
| payload | true | String(1, 1000) | Message content |
Example
Request body JSON parameters:
{
"roomId": "123456",
"userIds": ["user1", "user2", "user3"],
"payload": "Hello everyone!"
}
Response body JSON:
{
"code": 200,
"status": "success",
"message": "success"
}
WebSocket Message Broadcast Description
调用此接口成功后,系统会通过WebSocket向指定频道内的用户广播消息。
广播事件为 `customMessage`,广播内容为请求体中的 `payload` 字段。
例如:`io.emit('customMessage', payload);`
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure |
| status | String | Response result, determined by business logic; returns "success" or "error" |
| message | String | Response message |
| data | Object | Returns an empty object {} on success |
| error | Object | Error information when status code is non-200 [See details in Error Field Description] |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to identify the specific error |
| desc | String | Error description, corresponding to error.code |
Error Example
{
"code": 400,
"status": "fail",
"message": "userIds is required"
}
{
"code": 400,
"status": "fail",
"message": "userIds is too long, max is 2000"
}
{
"code": 400,
"status": "fail",
"message": "系统繁忙,请等1秒后再试"
}
