Polyv Help Center

Help Center

Query Channel Donation Settings

Updated: 2023-03-15 10:54:26

API Description

1、获取全局或当前生效的打赏设置
2、接口支持https协议

API URL

http://api.polyv.net/live/v3/channel/donate/get

Request Method

GET

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are subject to rate limits. See details

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See Get Secret Key
timestamp true Long Current 13-digit millisecond timestamp, valid for 3 minutes
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate 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 your own server to relay requests to the POLYV server for response data. See Signature Generation Rules
channelId false String Channel ID. If not provided, returns global settings; otherwise, returns the currently effective settings.

Example

http://api.polyv.net/live/v3/channel/donate/get?appId=frlr1zazn3&sign=C2C75D35056DFC64E6678D705FFB1857&channelId=2149710&timestamp=1621844001298

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 indicates success, non-200 indicates failure. See Global Error Description
status String Response status text
message String Response description message. When code is 400 or 500, provides additional error details.
data Object Detailed donation settings. See data field description

data Field Description

Parameter Type Description
globalSettingEnabled String Whether to apply global settings. When retrieving global settings, this value is null.
Y: Apply global settings
N: Apply channel settings
donateCashEnabled String Cash donation toggle
donateGoodEnabled String Item donation toggle
donateTips String Donation prompt
cashMin Double Minimum donation amount
cashes Double[] Donation amount options
goods Array Donation item options. See goods field description
donatePointEnabled String Points donation toggle
pointUnit String Points donation unit

goods Field Description

Parameter Type Description
goodName String Item option name
goodImg String Image corresponding to the item option
goodPrice Float Price of the item option, in yuan
goodEnabled String Whether the item is enabled

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.

It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.

private static final Logger log = LoggerFactory.getLogger(PageInteractionTest.class);
/**
 * 查询频道打赏设置
 * @throws IOException
 */
@Test
public void testDonateGet() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId=super.appId;
    String appSecret=super.appSecret;
    String userId = super.userId;
    String timestamp=String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v3/channel/donate/get";
    String channelId = "2149710";

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);

    requestMap.put("channelId",channelId);

    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.get(url,requestMap);
    log.info("测试查询频道打赏设置接口返回值:{}",response);
    //do somethings
}

Response Example

For system global error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "globalSettingEnabled": "Y",
        "donateCashEnabled": "Y",
        "donateGoodEnabled": "Y",
        "donateTips": "打赏",
        "cashMin": 0.01,
        "donatePointEnabled": "N",
        "pointUnit": null,
        "cashes": [0.88, 6.66, 8.88, 18.88, 66.60, 88.80],
        "goods": [{
            "goodName": "鲜花",
            "goodImg": "//s1.videocc.net/default-img/donate/flower.png",
            "goodPrice": 0.00,
            "goodEnabled": "Y"
        }, {
            "goodName": "咖啡",
            "goodImg": "//s1.videocc.net/default-img/donate/coffee.png",
            "goodPrice": 0.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "点赞",
            "goodImg": "//s1.videocc.net/default-img/donate/like.png",
            "goodPrice": 1.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "掌声",
            "goodImg": "//s1.videocc.net/default-img/donate/handclap.png",
            "goodPrice": 2.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "666",
            "goodImg": "//s1.videocc.net/default-img/donate/666.png",
            "goodPrice": 6.66,
            "goodEnabled": "Y"
        }, {
            "goodName": "小星星",
            "goodImg": "//s1.videocc.net/default-img/donate/star.png",
            "goodPrice": 9.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "钻石",
            "goodImg": "//s1.videocc.net/default-img/donate/diamond.png",
            "goodPrice": 19.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "跑车",
            "goodImg": "//s1.videocc.net/default-img/donate/car.png",
            "goodPrice": 29.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "火箭",
            "goodImg": "//s1.videocc.net/default-img/donate/rocket.png",
            "goodPrice": 66.66,
            "goodEnabled": "Y"
        }]
    }
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询