Polyv Help Center

Help Center

Modify Default Template Gift Donation Settings

Updated: 2023-04-04 09:31:23

API Description

1、修改直播模板礼物打赏设置,礼物打赏又分为现金支付和积分支付
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

API URL

http://api.polyv.net/live/v4/user/donate/gift/update

Online API Call

Request Method

POST

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 details on obtaining keys
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 the customer's own server to relay requests to the POLYV server for response data. See signature generation rules

Request Body Parameter Description

Parameter Required Type Description
donateGiftEnabled true String Gift donation toggle, Y: Enable, N: Disable
giftDonate false Object Gift See TemplateGiftDonate field description

TemplateGiftDonate Parameter Description

Parameter Required Type Description
payWay false String Payment method, CASH: Cash payment, POINT: Points payment
pointUnit false String Points unit
cashPays false Array Cash payment list, array length 1-18 See GiftDonate field description
pointPays false Array Points payment list, array length 1-16 See GiftDonate field description

GiftDonate Parameter Description

Parameter Required Type Description
name false String Gift name
img true String Gift image URL
price false Float Gift price, default 0.01
enabled false String Toggle, Y: Enable, N: Disable, default is N

Example

http://api.polyv.net/live/v4/user/donate/gift/update?appId=frlr1zazn3&sign=ECDDF7902925D558426182348FE3925D&timestamp=1631091439270

Request body JSON parameters:

{
    "donateGiftEnabled": "Y",
    "giftDonate": {
        "cashPays": [
            {
                "img": "//s1.videocc.net/default-img/donate/666.png",
                "price": "666",
                "name": "现金礼物1",
                "enabled": "Y"
            }
        ],
        "pointUnit": "豆",
        "pointPays": [
            {
                "img": "//s1.videocc.net/default-img/donate/666.png",
                "price": "666",
                "name": "积分礼物1",
                "enabled": "Y"
            }
        ],
        "payWay": "CASH"
    }
}

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure
status String Response result, determined by business logic, success returns "success", failure returns "error"
success Boolean Response result, determined by business logic, success returns true, failure returns false
data Object Channel details returned on successful response
error Object Error information when status code is non-200 See Error field description
requestId String Request ID, a unique UUID generated for each request, used only for troubleshooting and debugging, should not be tied to business logic

Error Parameter Description

Parameter Type Description
code Integer Error code, used to identify the specific error cause
desc String Error description, corresponds to error.code

Java Request Example

For quick integration of the base 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, both contained 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 pools.

    private static final Logger log = LoggerFactory.getLogger(UserDonateTest.class);

    @Test
    public void updateChannelDonate() throws IOException, NoSuchAlgorithmException {
        String appId = super.appId;
        String appSecret = super.appSecret;
        String timestamp = String.valueOf(System.currentTimeMillis());
        //业务参数
        String url = "http://api.polyv.net/live/v4/user/donate/gift/update";
        
        //http 调用逻辑
        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("appId", appId);
        requestMap.put("timestamp", timestamp);
        
        requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
        
        Map<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("donateGiftEnabled","Y");
        Map<String, Object> giftDonateMap = new HashMap<>();
        giftDonateMap.put("payWay","CASH");
        giftDonateMap.put("pointUnit","豆");
        List<Map<String,Object>> cashPaysList = new ArrayList<>();
        Map<String,Object> cash1 = new HashMap<>();
        cash1.put("name","现金礼物1");
        cash1.put("img","//s1.videocc.net/default-img/donate/666.png");
        cash1.put("price","666");
        cash1.put("enabled","Y");
        cashPaysList.add(cash1);
        giftDonateMap.put("cashPays",cashPaysList);
        List<Map<String,Object>> pointPaysList = new ArrayList<>();
        Map<String,Object> point1 = new HashMap<>();
        point1.put("name","积分礼物1");
        point1.put("img","//s1.videocc.net/default-img/donate/666.png");
        point1.put("price","666");
        point1.put("enabled","Y");
        pointPaysList.add(point1);
        giftDonateMap.put("pointPays",pointPaysList);
        jsonMap.put("giftDonate",giftDonateMap);
        
        url = HttpUtil.appendUrl(url,requestMap);
        
        String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap),null);
        
        log.info("测试修改直播模板礼物打赏设置,返回值:{}", response);
    }

Response Example

Success Example

{
    "code": 200,
    "status": "success",
    "requestId": "5d413aa5dc6b4cc1b79d4374aa5ac974.63.16310914532009701",
    "data": null,
    "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360832547921601",
    "error": {
        "code": 20001,
        "desc": "application not found."
    },
    "success": false
}
联系客服,在线咨询
在线咨询