Polyv Help Center

Help Center

Set Cash Tips

Updated: 2022-09-02 18:08:07

API Description

1、设置频道或者全局现金打赏(带上频道号为设置频道现金打赏,不带频道号默认为全局现金打赏设置)
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

API URL

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

Online API Call

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended to ensure API security. API calls have frequency 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 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 and retrieve response data. See Signature Generation Rules
channelId false String Channel ID. If not provided, it applies to global settings.

Request Body Parameter Description

Parameter Required Type Description
cashes true Double[] Array of cash tip amounts. The array length must be 6.
cashMin true Double Minimum custom cash tip amount
enabled false String Cash tip toggle. Default is enabled if not provided.
N: Disabled
Y: Enabled

Example

http://api.polyv.net/live/v3/channel/donate/update-cash?appId=frlr1zazn3&sign=7E9C8EF6BB4919EBC717AAF65EFB8B19&channelId=2149710&timestamp=1621844038326

Request Body Parameters

{
    "cashes": [0.88, 6.66, 8.88, 18.11, 66.60, 88.80],
    "cashMin": 0.02,
    "enabled": "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, it 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 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 packaging 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 testUpdateCash() 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/update-cash";
   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 body = "{\"cashes\":[0.88,6.66,8.88,18.11,66.60,88.80],\"cashMin\":0.02,\"enabled\":\"Y\"}";
   url = HttpUtil.appendUrl(url, requestMap);
   String response = HttpUtil.postJsonBody(url, body, null);
   log.info("测试设置现金打赏接口返回值:{}",response);
   //do somethings

}

Response Example

For 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": ""
}
联系客服,在线咨询
在线咨询