DNS
Contents
    Loading
Support DNS DNSPod API Call Instance

DNSPod API Call Instance

DNSPod API Call Instances

For a program used to request an API, the User-Agent must be in the format of the program name/version (email address). Common browsers are not allowed to be forged; otherwise, the firewall of DNSPod may reject the requests.

For more samples, please see:

API library for Python
DNSPod DDNS client source code for C# (not the latest version and for reference only)

Sample Code for PHP + CURL (Not the Latest Version and for Reference Only)

Request submitting function:

function postData($url, $data) {

$data       = http_build_query($data);

$ch        = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

// curl_setopt($ch, CURLOPT_HEADER, 1);

// curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_USERAGENT, 'program name/version (email address)');

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response     = curl_exec($ch);

curl_close($ch);

return $response;

}

Add a new domain:

$data = array('login_email'            => 'foo@bar.com',

'login_password'        => 'password',

'format'              => 'xml',

'domain'              => 'test.com');

echo postData("https://dnsapi.cn/Domain.Create", $data);

Get the list of records for a single domain:

$data = array('login_email'           => 'foo@bar.com',

'login_password'        => 'password',

'format'              => 'xml',

'domain_id'            => '123456');

echo postData("https://dnsapi.cn/Record.List", $data);
Last updated on 2021-01-27 07:20