Skip to content

Commit

Permalink
Merge pull request #14 from MrSam/master
Browse files Browse the repository at this point in the history
Example6 with list,delete and add calls
  • Loading branch information
BenMenking committed Mar 4, 2016
2 parents c9f260f + c62d5e1 commit 36c6dae
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions examples/example6.php
@@ -0,0 +1,35 @@
<?php

/* 3 step action
1) fetch all static dns hosts
2) remove all static dns hosts
3) add example host
*/

require('../routeros_api.class.php');
$API = new RouterosAPI();

if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
# Get all current hosts
$API->write('/ip/dns/static/print');
$ips = $API->read();

# delete them all !
foreach($ips as $num => $ip_data) {
$API->write('/ip/dns/static/remove', false);
$API->write("=.id=" . $ip_data[".id"], true);
}

#add some new
$API->comm("/ip/dns/static/add", array(
"name" => "jefkeklak",
"address" => "1.2.3.4",
"ttl" => "1m"
));

#show me what you got
$API->write('/ip/dns/static/print');
$ips = $API->read();
var_dump($ips);
$API->disconnect();
}

0 comments on commit 36c6dae

Please sign in to comment.