I have a question. I am trying to connect to my Mikrotik via API but authentication has not been possible. In my Mikrotik log, the login failed. I'll leave the code snippet I'm using:
Code: Select all
<?php
use PEAR2\Net\RouterOS;
//require_once 'PEAR2/Autoload.php';
require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar';
try {
$client = new RouterOS\Client('192.168.1.100', 'admin', 'Thomas');
} catch (Exception $e) {
die('Unable to connect to the router.');
}
$addRequest = new RouterOS\Request('/ip/arp/add');
$addRequest->setArgument('address', '192.168.88.100');
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');
if ($client->sendSync($addRequest)->getType() !== Response::TYPE_FINAL) {
die("Error when creating ARP entry for '192.168.0.100'");
}
$addRequest->setArgument('address', '192.168.88.101');
$addRequest->setArgument('mac-address', '00:00:00:00:00:02');
if ($client->sendSync($addRequest)->getType() !== Response::TYPE_FINAL) {
die("Error when creating ARP entry for '192.168.0.101'");
}
echo 'OK';
Thanks in advance