温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.dns.com/en/docs/2/4
点击访问原文链接

API文档-DNS.COM

API文档-DNS.COM Home DNS Resolution DNS Intelligent Resolution Fast, secure, and stable smart DNS resolution services Custom Authoritative DNS Independent DNS servers + independent NS addresses DNS Pollution Treatment Domain Name SSL Certificates Server Rental Cloud Computing Services Cloud Server China Hong Kong Cloud Server China Hong Kong Optimized Bandwidth Cloud Server Japan Cloud Server US Cloud Server SG Cloud Server Lightweight Cloud Server Server Rental China Hong Kong Server China Hong Kong CN2 Server China Hong Kong SEO Server China Hong Kong Optimized Bandwidth Server China Hong Kong International Bandwidth Server China Hong Kong Anti-DDoS Server Japan Server Japan Optimized Bandwidth Server Japan International Bandwidth Server US Server US CN2 Server US SEO Server US Anti-DDoS Server Singapore Server SG CN2 Server SG Anti-DDoS Server DDoS protection Anti-DDoS IP China Hong Kong High-Protection IP Company About DNS.COM Global one-stop infrastructure security service provider Support Welcome to the Answer Contact Us Leave us a message or contact us via email AFF Join the AFF Program and earn your commissions API Docs Real-time request, calling API interface CN EN Register Sign In Control Station Sign Out API Docs Calling Method Common Parameters Signature Method Common Error Codes Domain Add Domain Domain List Manage Domain Get Domain Lines Get Domain Details DNS Records Record List Add Record Modify Record Manage Record Get Record Details Signature Method 1. Signature Method 2. Apply for Security Credentials 3. Generate Signature String 4. Signature Demo 1. Signature Method The DNS API authenticates every request. Each request must include a signature (hash) in the common request parameters to verify the user’s identity. The signature is generated using the user's security credentials, which include api_key and api_secret. If you do not have security credentials, you must apply for them on the DNS official website; otherwise, you cannot call the API.

2. Obtaining Security Credentials Before using the DNS API for the first time, users need to check their security credentials at API Key Management. The security credentials include:

api_key: Identifies the API caller. api_secret: The key used to encrypt the signature string and verify it on the server side. 3. Generating the Signature String With api_key and api_secret, you can generate the signature string. The process is as follows:

Sort Parameters Sort all request parameters in ascending order by parameter name (dictionary order). This is similar to how words are arranged in a dictionary: first by the first character, then by the second if the first is identical, and so on. You can use built-in sorting functions, such as ksort in PHP.

{ "api_key":"c7722149110b7492a2e5cf1d8f3f966b", "domain":"dns.com", "timestamp":"1521005892" } When developing with other programming languages, you can sort the parameters in the example above; as long as the resulting order is the same, the signature will be valid.

Concatenate Parameters Format the sorted parameters as parameterName=parameterValue. For example, for the domain parameter, "domain=dns.com". Then append api_secret to the end of the string.

api_secret=ecb4ff0e877a83292b9f35067e9ae673 Request string: api_key=c7722149110b7492a2e5cf1d8f3f966b&domain=dns.com ×tamp=1521005892 Final string: api_key=c7722149110b7492a2e5cf1d8f3f966b&domain=dns.com ×tamp=1521005892ecb4ff0e877a83292b9f35067e9ae673 Generate the Signature Use the signature algorithm (MD5) on the final string from Step 2 to generate the signature.

Example in PHP:

$lastStr = 'api_key=c7722149110b7492a2e5cf1d8f3f966b&domain=dns.com ×tamp=1521005892'; $signStr = md5($lastStr . 'ecb4ff0e877a83292b9f35067e9ae673'); echo $signStr; Resulting signature:

0eb4933a634000ce215370683d6f1338 Signature Demo {#4} PHP /** * 签名方法 * @param $parameters * @param $apiSecret * @return string */ function getHash($parameters,$apiSecret){ ksort($parameters); $hashString = ''; foreach($parameters as $key => $value){ $hashString .= ($hashString ? '&' : '') . $key . '=' . $value; } return md5($hashString . $apiSecret);; } $parameters = [ 'domain' => 'dns.com', 'timestamp' => time(), 'api_key' => 'your api_key' ]; echo getHash($parameters,'your api_secret'); GO package main import ( "crypto/md5" "encoding/hex" "fmt" "sort" ) func GetHash(param map[string]string, secert string) string { var keyList []string for k, _ := range param { keyList = append(keyList, k) } sort.Strings(keyList) var hashString string for _, key := range keyList { if hashString == "" { hashString += key + "=" + param[key] } else { hashString += "&" + key + "=" + param[key] } } m := md5.New() m.Write([]byte(hashString + secert)) cipherStr := m.Sum(nil) return hex.EncodeToString(cipherStr) } func main() { var param = map[string]string{} param["domain"] = "dns.com" param["timestamp"] = "1602734019" param["api_key"] = "your api_key" fmt.Println(GetHash(param, "your api_secret")) } Python import hashlib def GetHash(param, secert): hasString = "" for key in sorted(param): if hasString == "": hasString = key + "=" + param[key] else: hasString += "&" + key + "=" + param[key] hasString = hasString + secert signStr = hasString.encode(encoding='utf-8') sign = hashlib.md5(signStr).hexdigest() return sign if __name__ == '__main__': param = {"domain": "dns.com", "timestamp": "1602734019","api_key": "your api_key"} print(GetHash(param, "your api_secret")) Java package com.dns; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; public class App { public static String GetHash(Map param , String secert) throws NoSuchAlgorithmException{ Object[] keyList = param.keySet().toArray(); Arrays.sort(keyList); String hashString = ""; for (int i = 0; i (); param.put("domain","dns.com"); param.put("timestamp","1602734019"); param.put("api_key","your api_key"); String rsp = ""; try { rsp = GetHash(param,"your api_secret"); }catch (Exception e){ } System.out.println(rsp); } } C#(csharp) using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; namespace checksum { class MD5Hash { public static string GetHash(Dictionary param, string apiSecret) { var keyList = new List(); foreach (var item in param) { keyList.Add(item.Key); } keyList.Sort(StringComparer.Ordinal); string hashString = ""; foreach (var key in keyList) { if (hashString == "") { hashString += key + "=" + param[key]; } else { hashString += "&" + key + "=" + param[key]; } } return MD5Hash.createMD5(hashString + apiSecret); } public static string createMD5(string input) { MD5 md5 = MD5.Create(); byte[] inputBytes = Encoding.ASCII.GetBytes(input); byte[] hashBytes = md5.ComputeHash(inputBytes); StringBuilder sb = new StringBuilder(); for (int i = 0; i 24/7/365 support.
We work when you work Telegram E-mail Work Order Support Contact Us Online Customer service Technical Support:support@dns.com Business Cooperation:marker@dns.com Popular products DNS Intelligent Resolution DNS Pollution Treatment Domain Name SSL Certificates Cloud Computing Services China Hong Kong Cloud Server Japan Cloud Server US Cloud Server SG Cloud Server Server Rental China Hong Kong CN2 Server US CN2 Server SG CN2 Server Japan Optimized Bandwidth Server About DNS.COM About DNS.COM Support Glossary DNS Becky DNS Luna DNS Amy DNS NOC Title Email Address Type Market cooperation Marketing Cooperation Information Code Submit

智能索引记录