Skip to content

Commit c169e58

Browse files
committed
add dns_naptr_* api examples
1 parent 8d2f2ec commit c169e58

File tree

4 files changed

+201
-0
lines changed

4 files changed

+201
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
require 'soap_config.php';
4+
5+
$context = stream_context_create([
6+
'ssl' => [
7+
// set some SSL/TLS specific options
8+
'verify_peer' => false,
9+
'verify_peer_name' => false,
10+
'allow_self_signed' => true
11+
]
12+
]);
13+
14+
15+
$client = new SoapClient(null, array('location' => $soap_location,
16+
'uri' => $soap_uri,
17+
'trace' => 1,
18+
'exceptions' => 1,
19+
'stream_context' => $context));
20+
21+
22+
try {
23+
if($session_id = $client->login($username, $password)) {
24+
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
25+
}
26+
27+
$timestamp = date("Y-m-d H:i:s");
28+
29+
//* Set the function parameters.
30+
$client_id = 1;
31+
$params = array(
32+
'server_id' => 1,
33+
'zone' => 10,
34+
'name' => 'server',
35+
'type' => 'naptr',
36+
'data' => '100 "s" "thttp+L2R" "" thttp.example.com.',
37+
'aux' => '100',
38+
'ttl' => '3600',
39+
'active' => 'y',
40+
'stamp' => $timestamp,
41+
'serial' => '1',
42+
);
43+
44+
$id = $client->dns_naptr_add($session_id, $client_id, $params);
45+
46+
echo "ID: ".$id."<br>";
47+
48+
if($client->logout($session_id)) {
49+
echo 'Logged out.<br />';
50+
}
51+
52+
53+
} catch (SoapFault $e) {
54+
echo $client->__getLastResponse();
55+
die('SOAP Error: '.$e->getMessage());
56+
}
57+
58+
?>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
require 'soap_config.php';
4+
5+
$context = stream_context_create([
6+
'ssl' => [
7+
// set some SSL/TLS specific options
8+
'verify_peer' => false,
9+
'verify_peer_name' => false,
10+
'allow_self_signed' => true
11+
]
12+
]);
13+
14+
15+
$client = new SoapClient(null, array('location' => $soap_location,
16+
'uri' => $soap_uri,
17+
'trace' => 1,
18+
'exceptions' => 1,
19+
'stream_context' => $context));
20+
21+
22+
try {
23+
if($session_id = $client->login($username, $password)) {
24+
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
25+
}
26+
27+
//* Parameters
28+
$id = 11;
29+
30+
31+
$affected_rows = $client->dns_naptr_delete($session_id, $id);
32+
33+
echo "Number of records that have been deleted: ".$affected_rows."<br>";
34+
35+
if($client->logout($session_id)) {
36+
echo 'Logged out.<br />';
37+
}
38+
39+
40+
} catch (SoapFault $e) {
41+
echo $client->__getLastResponse();
42+
die('SOAP Error: '.$e->getMessage());
43+
}
44+
45+
?>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
require 'soap_config.php';
4+
5+
6+
$context = stream_context_create([
7+
'ssl' => [
8+
// set some SSL/TLS specific options
9+
'verify_peer' => false,
10+
'verify_peer_name' => false,
11+
'allow_self_signed' => true
12+
]
13+
]);
14+
15+
16+
$client = new SoapClient(null, array('location' => $soap_location,
17+
'uri' => $soap_uri,
18+
'trace' => 1,
19+
'exceptions' => 1,
20+
'stream_context' => $context));
21+
22+
23+
try {
24+
if($session_id = $client->login($username, $password)) {
25+
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
26+
}
27+
28+
//* Set the function parameters.
29+
$id = 11;
30+
31+
$dns_record = $client->dns_naptr_get($session_id, $id);
32+
33+
print_r($dns_record);
34+
35+
if($client->logout($session_id)) {
36+
echo 'Logged out.<br />';
37+
}
38+
39+
40+
} catch (SoapFault $e) {
41+
echo $client->__getLastResponse();
42+
die('SOAP Error: '.$e->getMessage());
43+
}
44+
45+
?>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
require 'soap_config.php';
4+
5+
6+
$context = stream_context_create([
7+
'ssl' => [
8+
// set some SSL/TLS specific options
9+
'verify_peer' => false,
10+
'verify_peer_name' => false,
11+
'allow_self_signed' => true
12+
]
13+
]);
14+
15+
16+
$client = new SoapClient(null, array('location' => $soap_location,
17+
'uri' => $soap_uri,
18+
'trace' => 1,
19+
'exceptions' => 1,
20+
'stream_context' => $context));
21+
22+
23+
try {
24+
if($session_id = $client->login($username, $password)) {
25+
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
26+
}
27+
28+
//* Parameters
29+
$id = 11;
30+
$client_id = 1;
31+
32+
33+
//* Get the dns record
34+
$dns_record = $client->dns_naptr_get($session_id, $id);
35+
36+
//* Change active to inactive
37+
$dns_record['active'] = 'n';
38+
39+
$affected_rows = $client->dns_naptr_update($session_id, $client_id, $id, $dns_record);
40+
41+
echo "Number of records that have been changed in the database: ".$affected_rows."<br>";
42+
43+
if($client->logout($session_id)) {
44+
echo 'Logged out.<br />';
45+
}
46+
47+
48+
} catch (SoapFault $e) {
49+
echo $client->__getLastResponse();
50+
die('SOAP Error: '.$e->getMessage());
51+
}
52+
53+
?>

0 commit comments

Comments
 (0)