<?php
$apiKey = "cloudflareapikey";
$email = "test@r10.net";
$zoneId = "yourzoneid"; // Etki alanınızın kimliği
$apiUrl = "https://api.cloudflare.com/client/v4/zones/{$zoneId}/dns_records";
$subdomains = [
"market.r10net",
"blog.r10.net",
// Diğer alt etki alanlarını burada ekleyin
];
$ipAddress = "192.168.1.1";
foreach ($subdomains as $subdomain) {
$recordData = [
"type" => "A",
"name" => $subdomain,
"content" => $ipAddress,
"proxied" => false
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"X-Auth-Email: {$email}",
"X-Auth-Key: {$apiKey}",
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($recordData));
$response = curl_exec($ch);
curl_close($ch);
$responseData = json_decode($response, true);
if (isset($responseData['success']) && $responseData['success']) {
echo "DNS Record for '{$subdomain}' added successfully.\n";
} else {
echo "Failed to add DNS Record for '{$subdomain}'. Error: " . $responseData['errors'][0]['message'] . "\n";
}
}
?>