how set user using php api

Hello community!

I´m from Brazil and my english is poor.

Thank you for any help…

I try this script below but it don´t work:

require(‘routeros_api.class.php’);

$API = new routeros_api();

$API->debug = true;

// user test
$ip = ‘xxx.xxx.xxx.xxx’;
$usuario = ‘teste4’; // full same admin
$senha = ‘123456’;


if ($API->connect($ip, $usuario, $senha))
{

//I intent set the name of user above
$API->write(‘/user/set teste4
=name=teste3’);


$API->disconnect();

// i try connect with new name/user
$ip = ‘xxx.xxx.xxx.xxx’;
$usuario = ‘teste3’;
$senha = ‘123456’;

//Here can´t connect
if ($API->connect($ip, $usuario, $senha))
{
$API->write(‘/interface/getall’);

$ARRAY = $API->read();

print_r($ARRAY);

$API->disconnect();
}

}


The answer;

Connection attempt #1 to 192.168.200.221:8728…
<<< [6] /login

[5/5 bytes read.
[5, 39] !done
[37/37 bytes read.
[37, 1] =ret=e03816502927efa864b8a4ba6431b029
<<< [6] /login
<<< [12] =name=teste4
<<< [44] =response=00c2b343666183c7d5f34d1c1a4a5bc764
[5/5 bytes read.
[5, 1] !done
Connected…
<<< [16] /user/set teste4
<<< [12] =name=teste3
Disconnected…
Connection attempt #1 to 192.168.200.221:8728…

<<< [6] /login

[5/5 bytes read.
[5, 39] !done
[37/37 bytes read.
[37, 1] =ret=13284cdfc26c2827f6546815d976fa06
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=004c48a00835dbc34a312ddfcd544ecdd9
[5/5 bytes read.
[5, 31] !trap
[22/22 bytes read.
[22, 8] =message=cannot log in
[5/5 bytes read.
[5, 1] !done
Connection attempt #2 to 192.168.200.221:8728…
<<< [6] /login
[5/5 bytes read.
[5, 39] !done
[37/37 bytes read.
[37, 1] =ret=afa644dff9667c92fbb42327d19bd16c
<<< [6] /login

<<< [12] =name=teste3
<<< [44] =response=00ff7abf6c0c2852079b86832eca464754

[5/5 bytes read.
[5, 31] !trap
[22/22 bytes read.
[22, 8] =message=cannot log in
[5/5 bytes read.
[5, 1] !done
Connection attempt #3 to 192.168.200.221:8728…
<<< [6] /login
[5/5 bytes read.
[5, 39] !done
[37/37 bytes read.
[37, 1] =ret=82723729cf850399c10051f6e80c407b
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00cd86c6e6ba00d5e47ac1615d08491335
[5/5 bytes read.
[5, 31] !trap
[22/22 bytes read.
[22, 8] =message=cannot log in
[5/5 bytes read.
[5, 1] !done
Connection attempt #4 to 192.168.200.221:8728…

<<< [6] /login

[5/5 bytes read.
[5, 39] !done
[37/37 bytes read.
[37, 1] =ret=525e65e4820f61d2505b6c38ebf82208
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00d5a43d2f1cfb3732e91a9f291ee30582
[5/5 bytes read.
[5, 31] !trap
[22/22 bytes read.
[22, 8] =message=cannot log in
[5/5 bytes read.
[5, 1] !done
Connection attempt #5 to 192.168.200.221:8728…
<<< [6] /login
[5/5 bytes read.
[5, 39] !done
[37/37 bytes read.
[37, 1] =ret=595652cd89f96a3b7c85616e660de100
<<< [6] /login

<<< [12] =name=teste3
<<< [44] =response=00272ecd8ba933b95e7d37d4a72e49d197

[5/5 bytes read.
[5, 31] !trap
[22/22 bytes read.
[22, 8] =message=cannot log in
[5/5 bytes read.
[5, 1] !done
Error…

------------------------------ Any body help?

http://forum.mikrotik.com/t/change-hotspot-password-with-php-api/34773/31

Please don’t double post questions. You already got a reply there, but anyone that doesn’t know that would now duplicate efforts.

Ok. Not my intent. If you know how to delete the first post, i prefer this here because it a independent post.

Thank you.

Since you already got a reply there you cannot delete anymore. Just post again and link to here I guess.

Ok. I do that.

Thank you.

Chupaka answered here:

http://forum.mikrotik.com/t/change-hotspot-password-with-php-api/34773/45

Thx Chupaka.

Everybory, please, visit the link to see de result and the code at the end of post.