我正在使用curl(PHP)将记录添加到我的区域中;我想将test.gen.ng添加为具有名称服务器(ns1.test.com,ns2.test.com,ns3.test.com,ns4.test.com)的DNS记录。我可以添加A记录,CNAME记录和其他记录,并在底部添加代码,但不能添加NS记录。
{“成功”:false,“错误”:[{“代码”:1004,“消息”:“ DNS验证错误”,“ error_chain”:[{“代码”:9102,“消息”:“内容必须为字符串。“}]}],”消息“:[],”结果“:空}
我有上面显示的错误;发送以下内容。
<?php
/* Cloudflare.com | APİv4 | Api Ayarları */
$apikey = '61543253246426e7147'; // Cloudflare Global API
$email = 'rose@gen.ng'; // Cloudflare Email Adress
$domain = 'gen.ng'; // zone_name // Cloudflare Domain Name
$zoneid = 'a30b057777777777777777dadd'; // zone_id // Cloudflare Domain Zone ID
$dnsadgeldi = 'test';
$dnsnameserver1 = 'ns1.test.com';
$dnsnameserver2 = 'ns2.test.com';
$dnsnameserver3 = 'ns3.test.com';
$dnsnameserver4 = 'ns4.test.com';
$ttl = 120;
// A-record oluşturur DNS sistemi için.
$ch = curl_init("https://api.cloudflare.com/client/v4/zones/".$zoneid."/dns_records");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Auth-Email: '.$email.'',
'X-Auth-Key: '.$apikey.'',
'Cache-Control: no-cache',
// 'Content-Type: multipart/form-data; charset=utf-8',
'Content-Type:application/json',
'purge_everything: true'
));
// -d curl parametresi.
$data = array(
'type' => 'NS',
'name' => ''.$dnsadgeldi.'',
'content' => Array
(
'0' => $dnsnameserver1,
'1' => $dnsnameserver2,
'2' => $dnsnameserver3,
'3' => $dnsnameserver4
),
'zone_name' => ''.$domain.'',
'zone_id' => ''.$zoneid.'',
'proxiable' => 'false',
'proxied' => false,
'ttl' => 1
);
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
//curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data_string));
$sonuc = curl_exec($ch);
// If you want show output remove code slash.
// print_r($sonuc);
curl_close($ch);
echo $sonuc;