For anyone coming to this topic looking for a solution, this solution worked for me. Modify connect() function within RouterosAPI class thus:
public function connect($ip, $login, $password, $porta)
{
for ($ATTEMPT = 1; $ATTEMPT <= $this->attempts; $ATTEMPT++) {
$this->connected = false;
$PROTOCOL = ($this->ssl ? 'ssl://' : '' );
$context = stream_context_create(array('ssl' => array('ciphers' => 'ADH:ALL', 'verify_peer' => false, 'verify_peer_name' => false)));
$this->debug('Connection attempt #' . $ATTEMPT . ' to ' . $PROTOCOL . $ip . ':' . $porta . '...');
$this->socket = @stream_socket_client($PROTOCOL . $ip.':'. $porta, $this->error_no, $this->error_str, $this->timeout, STREAM_CLIENT_CONNECT);
if ($this->socket) {
socket_set_timeout($this->socket, $this->timeout);
$this->write('/login');
$this->write('=name=' . $login, false);
$this->write('=password=' . $password, false);
$RESPONSE = $this->read(false);
/if (isset($RESPONSE[0]) && $RESPONSE[0] == '!done') {
$this->connected = true;
/*
// see notes at https://wiki.mikrotik.com/wiki/Manual:API#Initial_login
$MATCHES = array();
if (preg_match_all('/[^=]+/i', $RESPONSE[1], $MATCHES)) {
if ($MATCHES[0][0] == 'ret' && strlen($MATCHES[0][1]) == 32) {
$this->write('/login', false);
$this->write('=name=' . $login, false);
$this->write('=response=00' . md5(chr(0) . $password . pack('H*', $MATCHES[0][1])));
mostra_array($this, 'api 116');
$RESPONSE = $this->read(false);mostra_array($RESPONSE, 'api 117 RESPONSE');
if (isset($RESPONSE[0]) && $RESPONSE[0] == '!done') {
$this->connected = true;
break;
}
}
}
*/
}
fclose($this->socket);
}
sleep($this->delay);
}
This is $RESPONSE object:
Connection attempt #1 to xx.xx.xx.197:21... <<< [6] /login <<< [14] =name=myLogin<<< [23] =password=myPassword >>> [5/5] bytes read. >>> [5, 39]!done >>> [37/37] bytes read. >>> [37, 1]=ret=2a26f0033901135c0c685bdbc6ffb5de Connected... Disconnected...