Login API pear2/Net_RouterOS 6.45.x

Hi,

I did read about new login API from 6.45.x version. https://wiki.mikrotik.com/wiki/Manual:API#Initial_login

Now I have several routers where I connect throw pear2/Net_RouterOS with versions older that 6.45 (arround 1000 routers). And now there start to come some with new RouterOS version.

I did found a new version on pear2/Net_RouterOS 1.0.0b6 (i’m using 1.0.0.b5) but on the change log I didn’t found login differences.

So how I have to do to keep working the api call with both verions ?

I’m doing at the moment:
$this->util = new RouterOS\Util($this->client = new RouterOS\Client($ip,$userRouter,$passRouter,null,null,$tiempoEspera));


Thanks,

Hi,


No one ? There is no fix ?

I do not see a problem you just try new login method and fall back if you receive ret, as shown in the python example:
https://wiki.mikrotik.com/wiki/Manual:API#Example_client

See “login” function

Thanks mrz,

but I’m using pers2/Net_RouterOS PHP class, I wonder if there is any update to don’t change the code directly.


it should be here:

private static function _login(
Communicator $com,
$username,
$password = ‘’,
$timeout = null
) {
$request = new Request(‘/login’);
$request->send($com);
$response = new Response($com, false, $timeout);
$request->setArgument(‘name’, $username);
$request->setArgument(
‘response’,
‘00’ . md5(
chr(0) . $password
. pack(‘H*’, $response->getProperty(‘ret’))
)
);
$request->send($com);
$response = new Response($com, false, $timeout);
return $response->getType() === Response::TYPE_FINAL
&& null === $response->getProperty(‘ret’);
}

If no ones have donne i will try but just if someone has done it would be grate to be shared.

Thanks,

Hi,

the code in this link is working for me until new realse or the API comes over.

https://github.com/pear2/Net_RouterOS/issues/37

Thanks,