Send Chat Room Product Information Socket Interface
Updated: 2022-09-02 18:08:07
Interface URL
http://api.polyv.net/live/v3/channel/chat/send-product-msg
Interface Description
- Sends chat room socket product information.
- The interface supports HTTPS.
- The interface request frequency is limited to 30 times per minute.
Supported Format
JSON
Request Method
POST
Request Limit
TRUE
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system. |
| timestamp | Yes | long | Current 13-digit millisecond timestamp, valid within 3 minutes. |
| sign | Yes | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not 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 for response data. See signature generation rules |
| channelId | Yes | int | Channel ID. |
| status | Yes | int | Operation type, must be an integer. 1: List product 2: Unlist product 3: Delete product 4: Add product 5: Edit product 6: Move up 7: Move down 9: Push 10: Product library toggle Currently, this status can be customized. 0-20 are platform parameters, 21 and above can be customized by the customer. |
Request Body Information
// 如下json,只有发送这种指定类型的json数据,polyv平台观看页才可以响应数据
// 如果发送其他自定义格式,需要自己开发观看页,接收到改socket 消息时自行进行处理。
// 请求体长度限制1000字符,如果超过,会返回错误。
// 4新增、5编辑、1上架、9推送
{
"cover": "//liveimages.videocc.net/uploadimage/20200827/chat_img_1779741_15985125681801.jpeg?x-oss-process=image/crop,x_95,y_0,w_235,h_235",
"link": "https://www.polyv.net",
"linkType": 10,
"mobileAppLink": "",
"mobileLink": "https://ngrok.io/",
"name": "66666666",
"params": "{\"222\": 123}",
"pcLink": "https://www.msuno.cn",
"price": 23.01,
"productId": 6282,
"rank": 18,
"realPrice": 11.02,
"showId": 6,
"status": 1,
"wxMiniprogramLink": "",
"wxMiniprogramOriginalId": ""
}
// 2下架(商品Id)、3删除
{
"productId": 5324
}
// 6上移、7下移(两个商品移动的id和排序和状态)
[
{
"channelId": 1779741,
"cover": "//liveimages.videocc.net/uploadimage/20200707/chat_img_1779741_15941160086266.jpeg?x-oss-process=image/crop,x_437,y_157,w_406,h_406",
"createdTime": 1594116013000,
"lastModified": 1599621435000,
"link": "http://www.msuno.cn",
"linkType": 10,
"mobileAppLink": "",
"mobileLink": "",
"name": "goods02",
"pcLink": "",
"price": 29,
"productId": 2129,
"rank": 15,
"realPrice": 12,
"showId": 3,
"status": 1,
"type": "live",
"userId": "ee7fe7fbda",
"wxMiniprogramLink": "",
"wxMiniprogramOriginalId": ""
},
{
"channelId": 1779741,
"cover": "//liveimages.videocc.net/uploadimage/20200910/chat_img_1779741_15997324532526.jpeg?x-oss-process=image/crop,x_280,y_0,w_719,h_719",
"createdTime": 1594116048000,
"lastModified": 1599756500000,
"link": "",
"linkType": 11,
"mobileAppLink": "",
"mobileLink": "",
"name": "1111",
"params": "{\"222\": 123}",
"pcLink": "https://www.msuno.cn",
"price": 23.01,
"productId": 2130,
"rank": 11,
"realPrice": 11.02,
"showId": 2,
"status": 1,
"type": "live",
"userId": "ee7fe7fbda",
"wxMiniprogramLink": "",
"wxMiniprogramOriginalId": ""
}
]
// 10商品库开关
{
"content": "",
"enabled": "N",
"menuId": "e30e6d716a",
"menuType": "buy",
"name": "边看边买",
"ordered": 6
}
Successful Response JSON Example:
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
Failed Response JSON Examples:
No appId entered
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
Incorrect appId
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
Timestamp error
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
Signature error
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Incorrect channel ID format
{
"code": 400,
"status": "error",
"message": "param is not digit: dsadasd",
"data": ""
}
Empty request body
{
"code": 400,
"status": "error",
"message": "param should not be empty: msg",
"data": ""
}
Request body data too long
{
"code": 400,
"status": "error",
"message": "param length is incorrect: 1000",
"data": ""
}
Field Description
| Parameter | Description |
|---|---|
| code | Response code. 200 for success, 400 for failure, 401 for signature error, 500 for server error. |
| status | "success" for success, "error" for failure. |
| message | Error message when an error occurs. |
| data | Currently has no function and should not be used as a basis for judgment. |
Java Request Example
public static void main(String[] args) {
String url = "http://api.polyv.net/live/v3/channel/chat/send-product-msg";
// 用户对应的appId和加密串
String appId = "xxxxxx";
String appSecret = "xxxxxxxxxxxxxxxxxxxxxxx";
// 查询频道号
String channelId = "1796673";
Map<String, String> params = new HashMap<>();
params.put("channelId", channelId);
params.put("status", "1");
// 调用Polyv的工具类方法设置sign
PolyvTool.setLiveSign(params, appId, appSecret);
// 调用Polyv的httpClient工具类发送请求
String content = HttpClientUtil.getInstance()
.sendHttpPostJson(url + "?" + PolyvTool.mapJoinNotEncode(params), "json请求体", null);
System.out.println(content);
}
