I am working on adding records to my zone using curl (PHP); I want to add test.gen.ng as the DNS record with nameservers (ns1.test.com, ns2.test.com, ns3.test.com, ns4.test.com). I am able to add A records, CNAME records and others with the code at the bottom but not NS records.
{"success":false,"errors":[{"code":1004,"message":"DNS Validation Error","error_chain":[{"code":9102,"message":"content must be a string."}]}],"messages":[],"result":null}I am having errors as shown above; sending the content below. Please, how do I send the content as required by cloudflare?<?php
/* Cloudflare.com | APİv4 | Api Ayarları */
$apikey = $this->data["apikey"]; //'430255a2117147'; // Cloudflare Global API
$email = $this->data["email"]; //'go@roswed.com'; // Cloudflare Email Adress
$domain = $this->data["tld"]; //'gen.ng'; // zone_name // Cloudflare Domain Nam
$zoneid = $this->data["zoneID"]; //'a203c506cbafc';
$this->data["DomainName"] = $this->get("loop_event10.row.Registry.sld");
$this->data["NameServer1"] = $this->get("loop_event10.row.Registry.nameserver1");
$this->data["NameServer2"] = $this->get("loop_event10.row.Registry.nameserver2");
$this->data["NameServer3"] = $this->get("loop_event10.row.Registry.nameserver3");
$this->data["NameServer4"] = $this->get("loop_event10.row.Registry.nameserver4");
$this->data["TTL"] = 1;
// 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' => ''.$this->data["DomainName"].'',
'content' => Array
(
'0' => $this->data["NameServer1"],
'1' => $this->data["NameServer2"],
'2' => $this->data["NameServer3"],
'3' => $this->data["NameServer4"]
),
'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;
?>
Says it right there doesn't it mate? "Content must be a string" and yet you're trying to send an array?
This topic is locked and no more replies can be posted.
