-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathcustom_connector.php
38 lines (27 loc) · 1.23 KB
/
custom_connector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/CliLogger.php';
require __DIR__.'/BasicAuthConnector.php';
// This example will create a new domain and adds some default DNS records.
use Exonet\Powerdns\Powerdns;
use Exonet\Powerdns\RecordType;
$domain = 'dns-new-zone-test.nl';
$nameServers = ['ns1.example.com.', 'ns2.example.eu.'];
$dnsRecords = [
['name' => '@', 'type' => RecordType::A, 'content' => '127.0.0.1', 'ttl' => 60],
['name' => 'www', 'type' => RecordType::A, 'content' => '127.0.0.1', 'ttl' => 60],
];
try {
// Update the key to the real PowerDNS API Key.
$powerdns = new Powerdns('127.0.0.1', 'secret', 8045);
// Set a custom connector.
$powerdns->setConnector(new BasicAuthConnector($powerdns, null, 'this-is-me', 'fancy-password'));
// Uncomment this line to see what happens when executing this example on the command line.
$powerdns->setLogger(new CliLogger());
// Uncomment this line if you want to run this example multiple times.
// $powerdns->deleteZone($domain);
// Create a new zone with the defined records and name servers.
$powerdns->createZone($domain, $nameServers)->create($dnsRecords);
} catch (Exception $exception) {
print_r($exception);
}