Modify Channel Gift Donation Settings
Updated: 2023-04-04 09:31:23
API Description
1、修改频道礼物打赏设置,礼物打赏又分为现金支付和积分支付
2、接口支持https协议
API URL
http://api.polyv.net/live/v4/channel/donate/gift/update
Request Method
POST
API Constraints
- 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 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 not be stored directly on the client. All APIs must be relayed through the customer's own server to call the POLYV server for response data. See signature generation rules |
| channelId | true | String | Channel ID |
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 |
| enabled | false | String | Toggle, Y: Enable, N: Disable, default is N |
| imgType | false | String | Gift type STATIC-Static gift DYNAMIC-Dynamic gift, default is static gift |
| img | false | String | Gift image URL, required when gift type is STATIC |
| dynamicImg | false | String | Dynamic thumbnail, PNG format, image size 500 x 500px, required when gift type is DYNAMIC |
| dynamicFile | false | String | Dynamic file, file type SVGA format, required when gift type is DYNAMIC |
| price | false | Float | Gift price, default 0.01 |
Example
http://api.polyv.net/live/v4/channel/donate/gift/update?appId=frlr1zazn3&sign=4B959FF84D977786673626B21F2E8EE3&channelId=2523307×tamp=1631090638818
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, success returns success, failure returns error |
| success | Boolean | Response result, determined by business, 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, only for troubleshooting and debugging, should not be tied to business |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to determine the specific error cause |
| desc | String | Error description, corresponds to error.code |
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. HttpUtil.java and LiveSignUtil.java in the test cases are included in the download file.
It is strongly recommended to use the Live Java SDK for API functionality 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(ChannelDonateTest.class);
@Test
public void testUpdateDonate() 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/channel/donate/gift/update";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", "2523307");
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": "dc7ae621ef8e4f4a8e4976833f1dbbd4.69.16309852981551185",
"data": null,
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360827277211321",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
