PHP: get user information

Hi all!

I have no idea about the syntax to get the user information with a PHP script.

For example, if I want to get the password from the user “test”?


I tried to do so:

$API = new routeros_api();
$API->debug = true;

if ($API->connect('172.16.14.30', 'UserX', 'UserX.2011')) {
	$API->write('/tool/user-manager/user/find');
	$API->write('?first-name', false);
	
	$READ = $API->read(false);
	$ARRAY = $API->parse_response($READ);
	
   	...

Thanks a lot!

Samoji

I still try but it doesn’t work and I don’t understand why

$API->write("/tool/user-manager/user/set", false);
$API->write("?name=\"" . $phone . "\"", false);
$API->write("=password=" . $password);

I get this response

Connected... <<< 
[27] /tool/user-manager/user/set <<< 
[19] ?name="thephonenumber" <<< 
[14] =password=thepassword >>> 
[5/5 bytes read. >>> 
[5, 1] !done

I solved doing this:


$phone = $ARRAY[0]["phone"];
$password = generatePassword($length, $strength);
				
$API->write("/tool/user-manager/user/set", false); 
$API->write("=.id=" . $phone, false);
$API->write("=password=" . $password);

Samoji