Create DNS record (permission needed: #dns_records:edit)
Create a new DNS record for a zone. See the record object definitions for required attributes for each record type
public create ( string $zone_identifier, string $type, string $name, string $content, integer | null $ttl = null, boolean | null $proxied = null, integer | null $priority = null, array | null $data = null ) | ||
$zone_identifier | string | |
$type | string | DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) |
$name | string | DNS record name |
$content | string | DNS record content |
$ttl | integer | null | Time to live for DNS record. Value of 1 is 'automatic' |
$proxied | boolean | null | Whether to proxy the domain through CloudFlare or not |
$priority | integer | null | MX record priority value |
$data | array | null | Additional data required for SRV record |
protected function updateDns($domain) { $dns = new Dns(getenv('CLOUDFLARE_API_EMAIL'), getenv('CLOUDFLARE_API_KEY')); $cloudflareIds = array(); foreach (Server::get() as $ip) { // Create DNS record $response = $dns->create(getenv('CLOUDFLARE_ZONE_ID'), 'A', $domain, $ip); if ($response->result->id !== null) { $cloudflareIds[] = $response->result->id; } } return $cloudflareIds; }