Polyv Help Center

Help Center

channelTemplate

Updated: 2025-09-11 15:18:09

1. Query Live Template Donation Settings

Description

查询直播模板打赏设置,包括现金打赏、礼物打赏,礼物打赏又分为现金支付和积分支付
接口地址(仅做说明使用):https://api.polyv.net/live/v4/user/donate/get

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetUserDonate() throws IOException, NoSuchAlgorithmException {
        LiveGetUserDonateRequest liveGetUserDonateRequest = new LiveGetUserDonateRequest();
        LiveGetUserDonateResponse liveGetUserDonateResponse;
        try {
            liveGetUserDonateResponse = new LiveChannelTemplateServiceImpl().getUserDonate(liveGetUserDonateRequest);
            Assert.assertNotNull(liveGetUserDonateResponse);
            if (liveGetUserDonateResponse != null) {
                //to do something ......
                log.debug("测试查询直播模板打赏设成功{}", JSON.toJSONString(liveGetUserDonateResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a LiveGetUserDonateResponse object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ].

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [ Error returned from Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Required Type Description
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official Website -> Login -> Live (Development Settings).

Return Object Description

Parameter Type Description
donateCashEnabled String Cash red envelope donation toggle, Y: Enabled, N: Disabled
cashDonate UserCashDonate Cash red envelope [See UserCashDonate Parameter Description]
donateGiftEnabled String Gift donation toggle, Y: Enabled, N: Disabled
giftDonate Array Gift donation (cash payment or points payment) [See UserGiftDonate Parameter Description]
UserCashDonate Parameter Description
Parameter Type Description
cashes Array Fixed donation amounts, array length 1-6, minimum 0.01, maximum 9999.99 [Corresponds to the cashs field in the API documentation]
cashMin Float Custom donation amount - minimum amount, minimum 0.01, maximum 9999.99
UserGiftDonate Parameter Description
Parameter Type Description
payWay String Payment method, CASH: Cash payment, POINT: Points payment
cashUnit String Cash unit
pointUnit String Points unit
cashPays Array Cash payment list [See ChannelGift Parameter Description]
pointPays Array Points payment list [See ChannelGift Parameter Description]
ChannelGift Parameter Description
Parameter Type Description
name String Gift name
img String Gift image URL
price Float Gift price
enabled String Toggle, Y: Enabled, N: Disabled
ChannelGift Parameter Description
Parameter Type Description
name String Gift name
img String Gift image URL
price Float Gift price
enabled String Toggle, Y: Enabled, N: Disabled






2. Modify Default Template Gift Donation Settings

Description

修改直播模板礼物打赏设置,礼物打赏又分为现金支付和积分支付
接口地址(仅做说明使用):https://api.polyv.net/live/v4/user/donate/gift/update

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateUserDonate() throws IOException, NoSuchAlgorithmException {
        LiveUpdateUserDonateRequest liveUpdateUserDonateRequest = new LiveUpdateUserDonateRequest();
        Boolean liveUpdateUserDonateResponse;
        try {
            LiveUpdateUserDonateRequest.UserGiftDonate giftDonate = new LiveUpdateUserDonateRequest.UserGiftDonate();
            List<LiveUpdateUserDonateRequest.UserGift> giftList = new ArrayList<>();
            LiveUpdateUserDonateRequest.UserGift gift1 = new LiveUpdateUserDonateRequest.UserGift();
            gift1.setImg("//liveimages.videocc.net/uploaded/images/2021/11/g41in083xo.png")
                    .setName("现金礼物")
                    .setPrice(Float.valueOf("1.66"))
                    .setEnabled(LiveConstant.Flag.YES.getFlag());
            giftList.add(gift1);
            List<LiveUpdateUserDonateRequest.UserGift> pointList = new ArrayList<>();
            LiveUpdateUserDonateRequest.UserGift pointGift1 = new LiveUpdateUserDonateRequest.UserGift();
            pointGift1.setImg("//s1.videocc.net/default-img/donate/666.png")
                    .setName("积分礼物")
                    .setPrice(Float.valueOf("12.88"))
                    .setEnabled(LiveConstant.Flag.YES.getFlag());
            LiveUpdateUserDonateRequest.UserGift pointGift2 = new LiveUpdateUserDonateRequest.UserGift();
            pointGift2.setImg("https://liveimages.videocc.net/uploaded/images/2021/11/g4b3010gmm.gif")
                    .setName("积分礼物2")
                    .setPrice(Float.valueOf("66.88"))
                    .setEnabled(LiveConstant.Flag.YES.getFlag());
            pointList.add(pointGift1);
            pointList.add(pointGift2);
            giftDonate.setPayWay(LiveConstant.PayWay.POINT.getValue())
                    .setCashPays(giftList)
                    .setPointPays(pointList)
                    .setPointUnit("polyv积分");
            liveUpdateUserDonateRequest.setGiftDonate(giftDonate);
            liveUpdateUserDonateRequest.setDonateGiftEnabled(LiveConstant.Flag.YES.getFlag());
            liveUpdateUserDonateResponse = new LiveChannelTemplateServiceImpl().updateUserDonate(
                    liveUpdateUserDonateRequest);
            Assert.assertTrue(liveUpdateUserDonateResponse);
            if (liveUpdateUserDonateResponse) {
                //to do something ......
                log.debug("测试修改默认模板礼物打赏设置成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }
}

Unit Test Description

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ].

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [ Error returned from Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Required Type Description
donateGiftEnabled false String Gift donation toggle, Y: Enabled, N: Disabled
giftDonate false UserGiftDonate Gift donation (cash payment or points payment) [See UserGiftDonate Parameter Description]
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official Website -> Login -> Live (Development Settings).
UserGiftDonate Parameter Description
Parameter Required Type Description
payWay false String Payment method, CASH: Cash payment, POINT: Points payment
cashUnit false String Cash unit
pointUnit false String Points unit
cashPays false Array Cash payment list [See UserGift Parameter Description]
pointPays false Array Points payment list [See UserGift Parameter Description]
UserGift Parameter Description
Parameter Required Type Description
name false String Gift name
img false String Gift image URL
price false Float Gift price
enabled false String Toggle, Y: Enabled, N: Disabled
UserGift Parameter Description
Parameter Required Type Description
name false String Gift name
img false String Gift image URL
price false Float Gift price
enabled false String Toggle, Y: Enabled, N: Disabled

Return Object Description

Entity returned for modifying default template gift donation settings

联系客服,在线咨询