-
Notifications
You must be signed in to change notification settings - Fork 4
Example 1
Nick Otter edited this page Jun 13, 2013
·
2 revisions
Origonally from: http://wiki.mikrotik.com/wiki/API_PHP_class#Example_1
###Example 1A
<?php
require_once "vendor/autoload.php";
use \RouterOS;
$API = new RouterOS\Core();
$API->debug = true;
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
$API->write('/interface/getall');
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
print_r($ARRAY);
$API->disconnect();
}
###Example 1B
<?php
require_once "vendor/autoload.php";
use \RouterOS;
$API = new RouterOS\Core();
$API->debug = true;
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
$API->write('/interface/getall');
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
}
###Example 1C
<?php
require_once "vendor/autoload.php";
use \RouterOS;
$API = new RouterOS\Core();
$API->debug = true;
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
$ARRAY = $API->comm('/interface/getall');
print_r($ARRAY);
$API->disconnect();
}
####Output
Array
(
[0] => Array
(
[.id] => *1
[name] => ether1
[mtu] => 1500
[type] => ether
[running] => yes
[dynamic] => no
[slave] => no
[comment] =>
[disabled] => no
)
[1] => Array
(
[.id] => *2
[name] => ether2
[mtu] => 1500
[type] => ether
[running] => yes
[dynamic] => no
[slave] => no
[comment] =>
[disabled] => no
)
[2] => Array
(
[.id] => *3
[name] => ether3
[mtu] => 1500
[type] => ether
[running] => yes
[dynamic] => no
[slave] => no
[comment] => ether3
[disabled] => no
)
)