ok.
so i want ahead and changed the line
$API->write('=.id='.$myusername,false);
to
$API->write('=.id=*1,false);
b’cos from the output i clearly see .id has a value of *1
it still behaved as if the password has been changed,but logging into the router shows otherwise.
i’m currently running v3.13 routeros
but i was suspecting maybe there is a bug so i upgraded to 3.22 and when i run the same code i get
Connection attempt #1 to 172.16.1.1:8728... <<< [6] /login >>> [5, 39] !done >>> [37, 1] =ret=3c459371715010e0476c6d91d2995876 <<< [6] /login <<< [11] =name=admin <<< [44] =response=00393c8c29e1e089dbbf83a720fc58bcc8 >>> [5, 1] !done Connected... <<< [23] /ip/hotspot/user/getall <<< [21] /ip/hotspot/user/set/ <<< [10] =.id=admin <<< [14] =password=test >>> [5, 35] !trap >>> [26, 8] =message=unknown parameter >>> [5, 1] !done Disconnected... Password Changed successfully!
what unknown parameter is it talking about?how can i identify it
i’m so confused now,but i never give up
back to your suggestion about the find,i came up with this code
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$myusername = $_POST["myusername"];
$mypassword = $_POST["mypassword"];
$newpassword= $_POST["newpassword"];
$ipofsvr="172.16.1.1";
if ($API->connect($ipofsvr,'admin',"")) {
$API->write('/ip/hotspot/user/getall');
$API->write('=.proplist=.id',false);
$API->write('?name='.$myusername);
$A = $API->read();
$A = $A[0];
echo "list .id value" .$A;
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->write('/ip/hotspot/user/set/',false);
$API->write('=.id='.$A['.id'],false);
$API->write('=password='.$newpassword);
$API->read();
$API->disconnect();
echo "Password Changed successfully!";
}
else
{
echo "Incorrect Username or Password! Please try again!";
$API->disconnect();
}
?>
when i run i get this output
Connection attempt #1 to 172.16.1.1:8728... <<< [6] /login >>> [5, 39] !done >>> [37, 1] =ret=c8e0d23ebe4ba26d3143df7ad2ba87a4 <<< [6] /login <<< [11] =name=admin <<< [44] =response=00e6d723bf535a6070e54f046d0acd1f26 >>> [5, 1] !done Connected... <<< [23] /ip/hotspot/user/getall <<< [14] =.proplist=.id <<< [11] ?name=admin >>> [5, 223] !trap >>> [31, 191] =message=no such command prefix >>> [5, 184] !done >>> [3, 179] !re >>> [7, 171] =.id=*1 >>> [9, 161] =comment= >>> [11, 149] =name=admin >>> [15, 133] =password=admin >>> [16, 116] =profile=default >>> [16, 99] =uptime=06:34:31 >>> [18, 80] =bytes-in=67384966 >>> [19, 60] =bytes-out=22911619 >>> [17, 42] =packets-in=63280 >>> [18, 23] =packets-out=29152 >>> [14, 8] =dynamic=false >>> [5, 1] !done list .id valueArray
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
people i need help with these codes,like i said this is my 1st time with php and api
this is line 217 of the routeros_api.class.php,i
if ((!$this->connected && !$STATUS['unread_bytes']) || ($this->connected && $_ == '!done' && !$STATUS['unread_bytes']))
does any1 have an updated version of routeros_api.class.php cos anyway i twist my code now i seem to get a an error on the above line,and elsewhere