Update DNS record (permission needed: #dns_records:edit)
public delete_record ( string $zone_identifier, string $identifier ) | ||
$zone_identifier | string | |
$identifier | string | API item identifier tag |
protected function updateDns(array $cloudflareIdentifiers, $domain) { $dns = new Dns(getenv('CLOUDFLARE_API_EMAIL'), getenv('CLOUDFLARE_API_KEY')); foreach ($cloudflareIdentifiers as $id) { $dns->delete_record(getenv('CLOUDFLARE_ZONE_ID'), $id); } $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; }