Polyv Help Center

Help Center

Batch Modify Distribution Addresses

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

API Description

1、修改分发地址
2、接口支持https协议

API URL

http://api.polyv.net/live/v4/channel/distribute/update-batch

Online API Call

Request Method

POST

API Constraints

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

  2. The push address cannot be modified while distribution streaming is in progress.

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 side. All APIs must be called through the customer's own server to relay requests to the POLYV server and obtain response data. See Signature Generation Rules
channelId true String Channel ID

Request Body Parameter Description

Type Required Description
Array true List of distribution address modification request objects See contents field description

contents Parameter Description

Parameter Required Type Description
id true String Cloud distribution ID
name false String Distribution address name, maximum length 20 characters
distributeUrl false String Push address, e.g., rtmp://polyv.net, must start with rtmp://, http://、https://
distributeLiveCode false String Live stream code

Example

http://api.polyv.net/live/v4/channel/distribute/update-batch?appId=frlr1zazn3&sign=849D052FC630787418BC1645CA17E2A7&channelId=2272655&timestamp=1639732654073

Request body JSON parameters:

[
    {
        "distributeUrl": "rtmp://xxx.xxxx.xxx",
        "distributeLiveCode": "testupdate",
        "name": "测试修改云分发",
        "id": "3159"
    }
]

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 Boolean Returns true on success
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 basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source 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 pools.

private static final Logger log = LoggerFactory.getLogger(getClass());
/**
 * 批量修改分分发地址
 * @throws IOException
 */
@Test
public void updateBatch() 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/v4/channel/distribute/update-batch";
    String channelId = "2272655";
    
    //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));
    url = HttpUtil.appendUrl(url, requestMap);
    
    List<Map<String, String>> bodyList = new ArrayList<>();
    Map<String, String> bodyMap = new HashMap<>();
    bodyMap.put("id", "3159");
    bodyMap.put("name", "测试修改云分发");
    bodyMap.put("distributeUrl", "rtmp://xxx.xxxx.xxx");
    bodyMap.put("distributeLiveCode", "testupdate");
    bodyList.add(bodyMap);
    
    String body = JSON.toJSONString(bodyList);
    
    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",
    "requestId": "e2e23029f14a46098842dde4d8f097b4.1943.16397326579270169",
    "data": true,
    "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "error": {
        "code": 10003,
        "desc": "时间戳过期"
    },
    "success": false
}
联系客服,在线咨询