观众进行积分打赏的接口

接口URL

https://api.polyv.net/live/v3/channel/donate/point/reward

接口说明

(接口调用有频率限制,详细请查看)

1、接口用于观众进行积分打赏的接口
2、接口支持https

返回结果格式

JSON

请求方式

POST

请求参数

参数名 必选 类型 说明
token string 接口请求的凭证
channelId int 频道号
viewerId string 观众ID
goodId int 打赏的ID
goodNum int 打赏的数量,默认为1
nickname string 观众昵称
avartar string 观众头像

响应成功JSON示例:

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

响应失败JSON示例:

token过期了

{
    "code": 400,
    "status": "error",
    "message": "token expired",
    "data": ""
}

非法的token

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

必填参数不能空

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

非法的访问

{
    "code": 400,
    "data": "",
    "message": "forbidden",
    "status": "error"
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为403,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data int,返回观众对应的可用积分数

Java请求示例

public static void test() {
        String url = "https://api.polyv.net/live/v3/channel/donate/point/reward";
        String token = "xxxxxxxxx";
        String viewerId = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
        int channelId = 10001;
        int goodId = 2;
        Map<String, String> params = new HashMap<>();
        params.put("channelId", channelId);
        params.put("viewerId", viewerId);
        params.put("token", token);
        params.put("goodId",goodId);
        // 调用Polyv的httpClient工具类发送请求
        String content = HttpClientUtil.getInstance()
                .sendHttpGet(url + "?" + PolyvTool.mapJoinNotEncode(params));
        System.out.println(content);
    }

签名规则(PolyvTool.java文件代码查看)

https://dev.polyv.net/2020/liveproduct/l-api/rule/live-api-java-detail/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...