This document provides general guidelines and instructions for API invocation.
QA Open Platform API Call
To call API operations on the open platform, you must create an application on the Quick Audience open platform. After an application is created, the system automatically generates an application ID, an AccessKey, and an AccessSecret. These key parameters are required for API calls.
Signature
After your application obtains the corresponding API permission, you can perform the following steps to call it: Attach the appId, accessKey, and timestamp (that is, the timestamp parameter) to the API URL that initiates the request. In addition, you must add the signed Authorization field to the request header.
Common parameters
Item | Example value | Location |
appId | the application id of the open platform. | Parameters section in the request URI |
accessKey | the ak of the application on the open platform | Parameters section in the request URI |
timestamp | Current timestamp (milliseconds) | Parameters section in the request URI |
Authorization | Generated signature | in the header of the request |
Perform the following steps to sign a request:
Use the request parameters to construct a canonicalized query string.
Sort all the parameters in the request (including the "public request parameters" described in the document and the custom parameters of the given request API) in the lexicographical order of the request parameters names. Note: When you use the GET method to submit a request, these parameters are the parameters in the request URI (that is, the part connected by "&" after "?" in the URI). The accessSecret is also required in the parameters used to generate the signature.
Names and values are encoded using the UTF-8 character set.
You must use urlEncode for all url parameters.
Code sample
The following Java code provides an example of the signature generation logic:
String appId="tttt";
String accessKey = "xxxx";
String accessSecret ="yyyy";
String timeStamp = "1708235644862";
SortedMap<String, String> map = new TreeMap<>();
map.put("appId", appId);
map.put("accessKey", accessKey);
map.put("accessSecret",accessSecret );
map.put("timestamp", timeStamp);
// If it is a get request and there are other query parameters, continue to add
String aa = getCanonicalQueryString(map);
System.out.println(aa);
String authorization = org.apache.commons.codec.digest.DigestUtils.md5Hex(aa);
System.out.println(authorization);public static String getCanonicalQueryString(SortedMap<String, String> paramsMap) {
StringBuilder queryString = new StringBuilder();
boolean isFirstParameter = true;
for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
String paramName = entry.getKey();
String value = entry.getValue();
if (!isFirstParameter) {
queryString.append("&");
} else {
isFirstParameter = false;
}
queryString.append(paramName).append("=").append(value);
}
return queryString.toString();
}Sample statement:
curl --location -g --request POST 'http://{quick audience public endpoint}/openapi/apipath/xxxx?appId=aaa&accessKey=xxx×tamp=yyy' \
--header 'Authorization: demosign'Auick Audience checks the signature based on the preceding parameters. if the application does not exist or the signature is incorrect, the application intercepts the request. for other API parameters, see the specific API document.
Domain Name
Environment | Domain Name | |
China (Zhangjiakou) | quicka.aliyun.com | |
China (Shanghai) | quicka-shanghai.aliyun.com |
Exception code
Exception code | Error message | Description |
ES05910010001 | The app does not exist. | Check whether the APP created on the open platform exists. |
ES05910010002 | The error code returned because the signature in the request is invalid. | Check whether the signature is generated correctly. |
ES05910010003 | The timestamp verification fails. | The generated timestamp must be called within 30 minutes. Otherwise, the verification fails. |
ES05910010004 | The application does not have the current API permission. | The application needs to subscribe to the API before it can be used. |
ES05910010005 | Check whether the appId, accessKey, and timestamp parameters are correct. | The public parameters appId, accessKey, and timestamp must be passed in accordance with the specifications of the platform. |