发送聊天室商品信息socket接口

接口URL

http://api.polyv.net/live/v3/channel/chat/send-product-msg

接口说明

1、发送聊天室socket商品信息

2、接口支持https

3、接口请求频次限制为每分钟30次

支持格式

JSON

请求方式

POST

请求数限制

TRUE

请求参数

参数名必选类型说明

appId

string

从API设置中获取,在直播系统登记的appId

timestamp

long

当前13位毫秒级时间戳,3分钟内有效

sign

String

签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则

channelId

int

频道号

status

int

操作类型,必须为整型 1:上架商品 2:下架商品 3:删除商品 4:新增商品 5:编辑商品 6:上移 7:下移 9:推送 10:商品库开关 目前这个status可以自定义,0-20为平台参数,21及其以上客户可自定义

请求体信息

// 如下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
}

响应成功JSON示例:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": true
}

响应失败JSON示例:

未输入appId

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

appId不正确

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

时间戳错误

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

签名错误

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

频道号格式错误

{
  "code": 400, 
  "status": "error", 
  "message": "param is not digit: dsadasd", 
  "data": ""
}

请求体为空

{
    "code": 400,
    "status": "error",
    "message": "param should not be empty: msg",
    "data": ""
}

请求体数据过长

{
    "code": 400,
    "status": "error",
    "message": "param length is incorrect: 1000",
    "data": ""
}

字段说明

参数名说明

code

响应代码,成功为200,失败为400,签名错误为401,异常错误500

status

成功为success,失败为error

message

错误时为错误提示消息

data

暂无作用,不可作为判断依据

Java请求示例

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);
    }

Last updated