cloudflare-php
cloudflare-php copied to clipboard
Support voor SRV records Add/ Update
Hi,
i am missing support for SRV records Add & Update
Same problem, i have tried to create an SRV record but it isn't working.
Add this function on vendor/cloudflare/sdk/src/Endpoints/DNS.PHP
public function addRecordSRV(
string $zoneID,
array $data = []
): bool {
$options = [
'type' => 'SRV'
];
if (!empty($data)) {
$options['data'] = $data;
}
$user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options);
$this->body = json_decode($user->getBody());
if (isset($this->body->result->id)) {
return true;
}
return false;
}
In your php file:
$query = [
'service' => '_exemple', // Service name
'proto' => '_tcp', // _tcp or _udp
'name' => 'exemple', // Record name
'priority' => 10, // Set your priority
'weight' => 10, // Set your weight
'port' => 64738, // Set your port
'target' => 's1.exemple.com'
];
$dns->addRecordSRV($zoneID, $query);
Add this function on vendor/cloudflare/sdk/src/Endpoints/DNS.PHP
public function addRecordSRV( string $zoneID, array $data = [] ): bool { $options = [ 'type' => 'SRV' ]; if (!empty($data)) { $options['data'] = $data; } $user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options); $this->body = json_decode($user->getBody()); if (isset($this->body->result->id)) { return true; } return false; }
In your php file:
$query = [ 'service' => '_exemple', // Service name 'proto' => '_tcp', // _tcp or _udp 'name' => 'exemple', // Record name 'priority' => 10, // Set your priority 'weight' => 10, // Set your weight 'port' => 64738, // Set your port 'target' => 's1.exemple.com' ]; $dns->addRecordSRV($zoneID, $query);
Open a Merge request so its ending up in the master as well :)
How is this not included yet?
@QuentinWehkamp I really don't know why Travis CI can't build the pull https://github.com/cloudflare/cloudflare-php/pull/160 So, probably that's why it hasn't been alerady merged.
Oh well, I'm glad a fix at least exists.