ROS 3.22 problem with API PHP on RB433

Hello community!!!


This code don´t work and i don´t know why:

$dt_mikrotik = 'Aug/26/2011';
$hr_form_final = '17:00:00';
$interval = '00:01:00';
$tarefa2 = 'test';
$generic_password = 123456;
$interval = '00:01:00';
$politica = 'read,write,policy';
$comando = '/user set password='.$generic_password.'  manut;
				
$API->write('/system/scheduler/add', false);
$API->write('=name='.$tarefa2, false);
$API->write('=start-date='.$dt_mikrotik, false);
$API->write('=start-time='.$hr_form_final, false);
$API->write('=interval='.$interval, false);
# $API->write('=policy='.$politica, false); (I can´t see this in winbox´s interface. So i comment.)
$API->write('=on-event='.$comando);
			
$ARRAY = $API->read();
								
$API->disconnect();

I test the same code in version v4.5 - RB433 and all fine. Anybody know the problem?

Thx any help. :confused:

$comando = '/user set password='.$generic_password.'  manut;

You have an unterminated string here. That line has three apostrophes ( ’ ) when they must be balanced.
You code as quoted couldn’t run against any ROS version because it is invalid in the language you’re writing in (probably PHP). That has nothing to do with the API itself.

Before suspecting the API and asking for help you should always use the linter to look for errors (‘php -l’), and probably always use a syntax highlighting editor that would make errors such as this easy to spot (where do the colors start looking funny?).

Sorry this is my error in ‘ctrl + c’ and ‘ctrl + v’.

$new_password = 654321;

The complet line:

$comando = '/user set password='.$new_password.'  manut; /system scheduler remove '.$tarefa;

The code don´t create a task in scheduller. But this occur in version 3.22 and not in 4.5. :frowning:

Any idea?

This is a command cli:

/system scheduler add name="test" start-date="Aug/26/2010" start-time="17:00:00" interval="00:01:00" on-event="/user  set  password=84d50a  manut;  /system  scheduler remove  abrir_ada749";

This work with winbox terminal in 3.22.

I ask this because i can´t see an answer for this in this forum (search) and in the documentation i have “This is PHP class for working with RouterOS v3 API”. Well, i´m a beginner and i don´t understand why ROS 3.22 don´t create a task in scheduller…

This:

$comando = '/user set password='.$new_password.'  manut';

don´t function. But this:


$comando = '/user set manut password='.$new_password;

work fine!

I test these in winbox terminal and in API PHP. Transfer position user´s name help me here. I don´t know if is the best way but work and i didn´t need upgrade de ROS of some boards. :smiley: