Polyv Help Center

Help Center

Set Gift Tipping

Updated: 2022-09-09 10:36:20

Interface Description

1、设置礼物打赏-现金支付礼物(旧版后台为:道具打赏)
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

Interface URL

http://api.polyv.net/live/v3/channel/donate/update-good

Online API Call

Request Method

POST

Interface Constraints

  1. The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details

  2. Only supports setting gift tipping - cash payment gifts. Pass the channel ID to set gift tipping for the specified channel. Without a channel ID, modify the general settings.

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details
timestamp true Long Current 13-digit millisecond timestamp, valid within 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 not be saved or used directly on the client. 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
channelId false String Channel ID. Leave empty to modify general settings (legacy backend general settings)

Request Body Parameter Description

Parameter Required Type Description
goods true Object Array of tipping gift objects. The number of objects must be greater than 0 and less than 10. See goods field description
enabled false String Tipping switch. Default is enabled if not passed.
Y: Enable
N: Disable

Goods Field Description

Parameter Required Type Description
goodName true String Gift name, cannot exceed 5 characters
goodImg true String Gift image, cannot exceed 120 characters (image URL can use the default address in the JSON string below, or obtain an image address via the image upload interface)
goodPrice true Float Gift tipping price, in yuan
goodEnabled true String Gift switch
Y: Enable
N: Disable

Example

http://api.polyv.net/live/v3/channel/donate/update-good?appId=frlr1zazn3&sign=3ADDD49DB62A77BFDC0CA62585A24011&channelId=2149710&timestamp=1621844081667

Request Body Parameters

{
    "enabled": "Y",
    "goods": [{
        "goodName": "鲜花333",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png",
        "goodPrice": 0,
        "goodEnabled": "Y"
    }, {
        "goodName": "咖啡",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png",
        "goodPrice": 0.99,
        "goodEnabled": "Y"
    }, {
        "goodName": "点赞",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png",
        "goodPrice": 1.99,
        "goodEnabled": "Y"
    }, {
        "goodName": "掌声",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png",
        "goodPrice": 2.99,
        "goodEnabled": "Y"
    }, {
        "goodName": "666",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png",
        "goodPrice": 6.66,
        "goodEnabled": "Y"
    }, {
        "goodName": "小星星",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png",
        "goodPrice": 9.99,
        "goodEnabled": "Y"
    }, {
        "goodName": "钻石",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png",
        "goodPrice": 19.99,
        "goodEnabled": "Y"
    }, {
        "goodName": "跑车",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png",
        "goodPrice": 29.99,
        "goodEnabled": "Y"
    }, {
        "goodName": "火箭233",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png",
        "goodPrice": 66.66,
        "goodEnabled": "Y"
    }]
}

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. When code is 400 or 500, provides additional error details
data String Returns true on success, empty on error

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click to download 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 testUpdateGood() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId=super.appId;
    String appSecret=super.appSecret;
    String userId = super.userId;
    String timestamp=String.valueOf(System.currentTimeMillis());
    //业务参数
    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 url = "http://api.polyv.net/live/v3/channel/donate/update-good";
    //拼接url
    url = HttpUtil.appendUrl(url, requestMap);
    String body = "{\"enabled\": \"Y\",\"goods\":[{\"goodName\":\"鲜花333\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png\",\"goodPrice\":0,\"goodEnabled\":\"Y\"},{\"goodName\":\"咖啡\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png\",\"goodPrice\":0.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"点赞\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png\",\"goodPrice\":1.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"掌声\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png\",\"goodPrice\":2.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"666\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png\",\"goodPrice\":6.66,\"goodEnabled\":\"Y\"},{\"goodName\":\"小星星\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png\",\"goodPrice\":9.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"钻石\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png\",\"goodPrice\":19.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"跑车\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png\",\"goodPrice\":29.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"火箭233\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png\",\"goodPrice\":66.66,\"goodEnabled\":\"Y\"}]}";
    String response = HttpUtil.postJsonBody(url,body,null);
    log.info("测试设置道具打赏接口返回值:{}",response);
    //do somethings
}

Response Example

For system-wide global error descriptions, see Global Error Description

Success Example

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

Error Example

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