Community discussions

MikroTik App
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Some exclusive api's command

Fri Jun 17, 2011 2:02 pm

Hello all,

i am new using in api. i read wiki also but can't get any help from that.

i added users successfully from the api in hotspot but i can't disable a user from api.
i am executing $API->comm("/ip/hotspot/user/disable/mani");
this command but it shows Array ( [!trap] => Array ( [0] => Array ( [message] => no such command ) ) )

Please tell me exact command and please also tell me how i can change password of a hotspot user from api.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Some exclusive api's command

Fri Jun 17, 2011 2:17 pm

"/ip/hotspot/user/disable/mani" there is no such command

to disable
/ip/hotspot/user/disable
=.id=<number returned by print>
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Fri Jun 17, 2011 6:23 pm

"/ip/hotspot/user/disable/mani" there is no such command

to disable
/ip/hotspot/user/disable
=.id=<number returned by print>
can you please tell me full command. where i can write username of hotspot user. can you please tell me.

and "mani" is username i want to disable. so please tell me full command and please also tell me about updating of password of the user from api.
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Sat Jun 18, 2011 10:51 am

waiting for answer
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Sat Jun 18, 2011 7:44 pm

anyone can please send me command..... waiting for answer.
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Mon Jun 20, 2011 12:28 pm

waiting for disable user complete command via API. anyone please send.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Some exclusive api's command

Tue Jun 21, 2011 9:45 am

/ip/hotspot/user/print
?name=mani
=.proplist=.id

Command above will return an ID.
put that <id> in command below.

/ip/hotspot/user/disable
=.id=<id>
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Tue Jun 21, 2011 12:31 pm

i will do this and update you shortly.
thanks for reply.
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Tue Jun 21, 2011 9:30 pm

/ip/hotspot/user/print
?name=mani
=.proplist=.id

Command above will return an ID.
put that <id> in command below.

/ip/hotspot/user/disable
=.id=<id>
Hello,

i used that command but not disable a user. My user id is 31. my code is this please check and if an error then please tell me about that
  
  <?php

require('routeros_api.class.php');

$API = new routeros_api();

$API->debug = false;

if ($API->connect('10.53.51.123', 'admin', 'admin213')) {
	
   $API->write('/ip/hotspot/user/disable');
   $API->write('=.id=31');
   

print_r($ARRAY);
   $API->disconnect();

}

?>
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Some exclusive api's command

Tue Jun 21, 2011 9:35 pm

First generate the ID via print, then use it.

Not to be mean, but the first reply in this thread told you that.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Some exclusive api's command

Wed Jun 22, 2011 9:31 am

+ 31 is not a valid internal id . Internal ids always start with *.
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Fri Jun 24, 2011 2:55 pm

is this command right for printing id
  <?php

require('routeros_api.class.php');

$API = new routeros_api();

$API->debug = false;

if ($API->connect('10.5.50.1', 'admin', 'adm44')) {
	
   $API->write('/ip/hotspot/user/print');
   $API->write('?name=mani');
   $API->write('=.proplist=.id');
   

print_r($ARRAY);
   $API->disconnect();

}

?>
?????
Last edited by rajamani779 on Fri Jun 24, 2011 7:22 pm, edited 1 time in total.
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Fri Jun 24, 2011 2:55 pm

can not getting any output from the above command. please tell me if anything wrong in the above command.
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Fri Jun 24, 2011 3:10 pm

With this command password of user mani is changing work fine but according to your command DISABLE of USER is not working.
  <?php

$myusername = "mani";
$newpassword= "234";

require('routeros_api.class.php');

$API = new routeros_api();

$API->debug = false;


if ($API->connect('10.5.50.1', 'admin', 'ad4455')) {

   echo "Password Changed successfully!";

   $API->write('/ip/hotspot/user/set',false);
   $API->write('=.id=*21',false);
   $API->write('=password='.$newpassword);

   $READ = $API->read(false);
   $ARRAY = $API->parse_response($READ);
   
   $API->disconnect();

}
?>
Please tell me correct disable of user command.

Thanks and waiting
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Sat Jun 25, 2011 2:23 pm

waiting....
for disable command...
 
marceloru
newbie
Posts: 48
Joined: Tue Jul 08, 2008 12:00 am
Location: Argentina

Re: Some exclusive api's command

Sun Jun 26, 2011 1:28 am

you are very close to the solution! still trying
I recommend posting in the section corresponding "RouterOS Community Support [Scripting]"
programmers are more in this section and will likely receive more aid
waiting....
for disable command...
 
rajamani779
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Sat Mar 26, 2011 7:56 pm

Re: Some exclusive api's command

Wed Jun 29, 2011 1:58 pm

you are very close to the solution! still trying
I recommend posting in the section corresponding "RouterOS Community Support [Scripting]"
programmers are more in this section and will likely receive more aid
waiting....
for disable command...
Thanks for moving my post.

i know i am very close.. but no answer still founded on my post.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Some exclusive api's command

Wed Jun 29, 2011 2:12 pm

either you have syntax error in commands or there are problems with your php api.

As I mentioned commads (tested and working) and output are:

/ip/hotspot/user/print
?name=lala
=.proplist=.id

!re
=.id=*1
!done

/ip/hotspot/user/remove
=.id=*1