Page 1 of 1

Simple commands via api (set ssid and enabling or disabling)

Posted: Tue Mar 11, 2014 1:26 am
by marcoramos
I'm new to the API
and I have done a few tries using the examples provided,
http://wiki.mikrotik.com/wiki/API_PHP_class


to change the ssid from my wireless interface that normaly i would use on the terminal
interface wireless set ssid="myMikro" numbers=0
, after this i wan't to enable or disable the wireless interface, but without luck also.
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;

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

//test 998
$ARRAY = $API->write('/interface/wireless/set/',array('numbers'=>0,'ssid'=>'skjdlksj'));
print_r($ARRAY);

//test 999
$ARRAY = $API->comm('/interface/wireless/set',array("numbers"=>0,"ssid"=>"sksksk2"));
print_r($ARRAY);

}
can anyone point what i'm doing wrong

Many thanks

Re: Simple commands via api (set ssid and enabling or disabl

Posted: Tue Mar 11, 2014 6:49 pm
by boen_robot
The API protocol does not support numbers. You typically need to use the item's ID.

In the case of interfaces, I believe you should also be able to use the interface name. I'm certain you can do that from the "/interface" menu at least.

Re: Simple commands via api (set ssid and enabling or disabl

Posted: Wed Mar 12, 2014 2:28 am
by marcoramos
that was it, many thanks

Re: Simple commands via api (set ssid and enabling or disabling)

Posted: Mon Jul 06, 2015 11:00 am
by jsturm
heei,
i know this is an old post,
but im strugling with this and cant figure it out how,
i cant get it working i got know
<?php

require('routeros_api.class.php');

$API = new routeros_api();

$API->debug = true;

if ($API->connect('XX.X.X.XXX', 'USERNAME', 'PASSWORD')) {

	$ARRAY = $API->write('/interface/wireless/set/',array('numbers'=>0 , 'ssid'=>'test123'));
	print_r($ARRAY); 

   $API->disconnect();

}

?>
can you tell me what u did?

Re: Simple commands via api (set ssid and enabling or disabling)

Posted: Wed May 18, 2016 8:36 am
by npongracic
Hello,
I also know this is an old post, but has anyone managed to get this working?
Im using something like this (not PHP but the principle is the same):

var commands = new List<string>() {
"/interface/wireless/set",
"=.id=wlan1",
"=address=" + ap.Address,
"=ssid=" + ap.SSID,
"=channel=" + ap.Channel,
"=radio-name=" + ap.RadioName
};

if (ap.SNR.HasValue)
{
commands.Add("=snr=" + ap.SNR.ToString());
}

if (ap.Signal.HasValue)
{
commands.Add("=sig=" + ap.Signal.ToString());
}

if (ap.NF.HasValue)
{
commands.Add("=nf=" + ap.NF.ToString());
}

if (!string.IsNullOrWhiteSpace(ap.Section))
{
commands.Add("=.section=" + ap.Section);
}

await Write(commands);

But this doesn't do anything. I've tried sending only ssid and .id but nothing.

Re: Simple commands via api (set ssid and enabling or disabling)

Posted: Tue Jun 14, 2016 11:10 am
by gszpiniak
Marco, could you please show us your last source code to set the SSID?.