Add custom resolution parameters to a client SDK or an HTTP API request to pass additional information during domain name resolution.
Add custom resolution parameters using the SDK
The following example uses the asynchronous resolution API of the Android SDK. For more information, see Custom resolution API.
// Pass custom resolution parameters using the custom resolution API.
Map<String, String> sdnsParams = new HashMap<>();
sdnsParams.put('osType', 'iOS');
HttpDnsService httpdns = HttpDns.getService(applicationContext, accountID, secretKey);
httpdns.getHttpDnsResultForHostAsync(
"www.aliyun.com", // The domain name to resolve.
RequestIpType.auto, // The type of IP address for resolution.
sdnsParams, // The custom resolution parameters.
cacheKey, // The cache key.
new HttpDnsCallback() {
void onHttpDnsCompleted(HTTPDNSResult result) {
// The callback function after the resolution is complete.
// todo something...
}
}
);
Add custom resolution parameters using an HTTP API operation
To resolve a domain name, use a URL in the following format:
http://203.107.XXX.XXX/{accountId}/d?host={domain-name}&ip={client-ip}&sdns-osType=iOS
-
Replace 203.107.XXX.XXX with the HTTPDNS service IP address. For more information, see Obtain the service IP address.
-
Replace {accountId} with your account ID from the console.
-
Replace {Domain name} with the domain name to resolve.
-
Replace {IP address of a specific line} with the client IP address to verify.
-
Prefix custom resolution parameters with
sdns-. Otherwise, the parameters are ignored. For example: sdns-osType=iOS.