Result Callback Interface Specification

Overview of the callback interface

A callback to the asynchronous interface for the review service .../check/submit, used to push the asynchronous detection review results to the customer.The customer needs to implement the interface for receiving the results according to the following specifications.

Interface Explanation

The results will be pushed to the customer using the dimensions taskId. If you need to use the callback function,

  • Method 1:Please go to theconsole-Service Configuration Configuration Callback URL(http protocol),callback area,the callback key is automatically generated after configuring the callback parameters.
  • Method 2:In.../check/ submit When the interface submits a task, it carries the corresponding callback parameters. See theOn-Demand Video Submission Interface/live stream video submission interface.

Note that the priority of using mode 2is greater than that of mode 1 ``.If you use the interface input method when submitting tasks, it will invalidate the callback parameters configured by the console.Please ensure that the input is correct. Additionally, when entering the interface, it is necessary to ensure callback URL, callback keyis not empty,otherwise the callback will not take effect. The client needs to ensure the availability and stability of the callback receiving interface to ensure normal reception of the pushed result data.

Interface Authentication

Customers can perform interface authentication through the key information field assigned after configuring the callback parameters. The specific methods are as follows:

Signature algorithm

  1. Sort the accepted request body parameters in ascending order according to the ASCII code table.
  2. Append the sorted parameters into a string. The format is:key1 + value1 +key2 +value2…
  3. After configuring the callback parameters, append the key generated to the string generated inStep 2.
  4. Encode the string generated byStep 3using UTF-8, encrypt it using MD5 to generate the signature parameter value, and place it in the request header.

Example Code

/**
 *Generate signature
 *@param secretKey backend key
 *@param params interface requests parameter names and parameter value maps, excluding signature parameter names
 *@return
 */
public static String signature(String secretKey, Map<String, String> params) {
    String[] keys = params.keySet().toArray(new String[0]);
    Arrays.sort(keys);

    StringBuilder signBuilder = new StringBuilder();
    for (String key : keys) {
        signBuilder.append(key).append(params.get(key));
    }
    signBuilder.append(secretKey);

    try {
        return DigestUtils.md5Hex(signBuilder.toString().getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        //error
    }
    return null;
}

Access Instructions

  • Protocol Explanation:The client needs to provide an interface that supports the HTTP protocol’s post request method.
  • Interface performance:Customers need to maintain the stability and reliability of the interface.
  • Failed Retest:After receiving a customer callback response, if it does not meet the required acceptance criteria, it will be considered a failed push. Will push 3 at specified intervals 10s If the third attempt continues to fail, the push will no longer continue. To obtain the results, call the Active Query Results interface.

Request for explanation

Request Address and Method

Name Value
callbackUrl callback address url(http protocol)
HTTP_METHOD POST

Request Head

Name Type Required Description
Content-Type String is fixed value:application/json
signature String is signature,verifying the legitimacy of the request,refer to the authentication algorithm

Request Parameters

Name Type Description
appId String Project Number
taskId String task id returned when submitting for asynchronous review
result String Review result
checkType String Detects item identifiers,such as video-check,audio-check, timeout disconnection, stream-closed

The result structure refers to getting the interface response

Live stream disconnection, callback reference

The logic for diagnosing :: HTTP connection disconnected,or according to the standard HTTP chunk protocol:finally received a line with chunk size=0 + CRLF

{
  "appId": "91200001",
  "taskId": "test_024c3621-4ee6-4d5d-9de8-5d553e319f90_1669957244196",
  "result": "{\"streamUrl\":\"rtmp://xxx.com/stream/103\",\"streamClosed\":true}",
  "checkType": "stream-closed"
}

Request Response

After the client interface receives the result of our callback, it needs to return a response message.The interface response codestatus code is 0.When the callback handles an exception,the response codestatus code should be 500, or 4xx; The response message is in JSON format, and the field is defined as follows:

Name Type Required Description
code Number is response code,a code value of 0 indicates that the callback was successful
message String No specific description information