DNSPod API 调用实例

例子代码PHP+CURL

提交请求的函数

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_POSTFIELDS, $data); $response = curl_exec($ch); curl_close($ch); return $response; }

添加一个新域名

$data = array('login_email'  => 'foo@bar.com',   'login_password' => 'password',   'format'   => 'xml',   'domain'   => 'test.com'); echo postData("http://www.dnspod.com/API/Domain.Create", $data);

获取单个域名的记录列表

$data = array('login_email'  => 'foo@bar.com, 'login_password' => 'password', 'format'   => 'xml', 'domain_id'   => '123456'); echo postData("http://www.dnspod.com/API/Record.List", $data);

修改一条记录

$data = array('login_email'  => 'foo@bar.com', 'login_password' => 'password', 'format'   => 'xml', 'domain_id'   => '123456', 'record_id'   => '7654321', 'sub_domain'  => 'test1234', 'record_type'  => '1', 'record_line'  => '1', 'value'    => '127.0.0.1', 'mx'    => '10', 'ttl'    => '3600'); echo postData("http://www.dnspod.com/API/Record.Modify", $data);