Hi,
i’m trying to disconnect some users with the command remove
follow the code
<?php
$host="192.168.3.10";
$usuario="admin";
$senha="admin";
require_once('classes/routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
echo"<br>
";
if ($API->connect("192.168.3.10", "admin", "admin" )) {
$API->write('/ppp/active/print');
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
print_r($ARRAY);
$API->write('/ppp/active/remove/0');
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
//$API->disconnect();
}
?>
the first command ppp/active/print is working
but the ppp/active/remove isn’t working
can somebody help me?
fewi
October 6, 2009, 3:59pm
2
“/ppp/active/remove/0” is not a valid API command. Refer to http://wiki.mikrotik.com/wiki/API for the syntax.
but… i used this commands
on the terminal and telnet
and they are working
fewi
October 6, 2009, 7:07pm
4
The API has a different syntax than the CLI. The wiki outlines the syntax to use.
ok thank you,
i’ll use shell + php to do this..
the php API is so good.. but need more commands
fewi
October 6, 2009, 7:27pm
6
What commands are you missing? You can remove entries via the API, just not with the syntax you’re using.
i need to do this command
ppp active remove $i
in API
fewi
October 6, 2009, 7:41pm
8
So follow the link to the wiki above to find out how to do that.
I do this oon terminal > /ppp active remove 0
on API $API->write(‘/ppp/active/remove/0’);
how i do this command /ppp active remove 0 on the API?
Chupaka
October 6, 2009, 11:16pm
11
first, you do
/ppp/active/print
=.proplist=.id
?name=something
then
/ppp/active/remove
=.id=*here_is_id_from_previous_command_result
but on the API PHP
$API->write(‘/ppp/active/remove/’);
$API->write(‘=.id=0’);
that’s right?
janisk
October 7, 2009, 12:33pm
13
yes, something like that, just use correct id numbers.
id numbers look something like this:
!re
=.id=*9
!re
=.id=*4402E70B
!re
=.id=*44038805
!re
=.id=*4403AC69
!re
=.id=*4403A3DB
!re
=.id=*30000003
!re
=.id=*440395C1
!re
=.id=*4403A083
!re
=.id=*44038CC1
!done
Hi,
isn’t working… the user is connected and the id = *6
the code above is not workin
$API->write(‘/ppp/active/remove’);
$API->write(‘=.id=*6’);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
what’s wrong?
$API->write(‘/ppp/active/remove’, false );
only last line of command should not contain second parameter
I need your help with this I tried to delete my hotspot users when they are active but I couldn’t
I tried with this in php
$var='someuser'
$BRIDGEINFO = $API->comm('/ip/hotspot/user/active/print', array(
".proplist" => ".id",
"?name" => "$var"
));
$API->comm('/ip/hotspot/active/remove', false, array(
".id"=>$BRIDGEINFO[0]['.id'],
));
maybe my code doesn't work can you tell me which is my mistakes
Chupaka
December 12, 2012, 10:30am
18
have you checked whether you get correct result in $BRIDGEINFO[0][‘.id’], for example?..
I tried to do this like when I have an Hotspot user and instead to disable an user I delete them and it works because when I put it, it catches me the id from user
something like that
$var="someuser";
$BRIDGEINFO = $API->comm('/ip/hotspot/user/print', array(
".proplist" => ".id",
"?name" => "$var"
));
$API->comm('/ip/hotspot/user/remove', array(
".id"=>$BRIDGEINFO[0]['.id'],
));
and it works
but it is only with my users from hotspot
it doesn’t work with my users that I have active and I want to delete them
and I tried also like this
$BRIDGEINFO = $API->comm('/ip/hotspot/user/print', array(
".proplist" => ".id",
"?name" => "$var"
));
mm('/ip/hotspot/user/active/remove', array(
".id"=>$BRIDGEINFO[0]['.id'],
));
but it doesn’t work, I could removed only my users from hotspot but I can’t do the same from my hotspot users when they are active and that is my big problem any idea? thanks anyway
In this code:
$BRIDGEINFO = $API->comm('/ip/hotspot/user/print', array(
".proplist" => ".id",
"?name" => "$var"
));
mm('/ip/hotspot/user/active/remove', array(
".id"=>$BRIDGEINFO[0]['.id'],
));
you’re getting the “user” ID, not the “user/active” ID, which is why the remove fails.
Try it as
$BRIDGEINFO = $API->comm('/ip/hotspot/user/active/print', array(
".proplist" => ".id",
"?name" => "$var"
));
mm('/ip/hotspot/user/active/remove', array(
".id"=>$BRIDGEINFO[0]['.id'],
));