Community discussions

MikroTik App
 
marcoramos
just joined
Topic Author
Posts: 2
Joined: Tue Mar 11, 2014 12:19 am

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

Tue Mar 11, 2014 1:26 am

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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

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

Tue Mar 11, 2014 6:49 pm

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.
 
marcoramos
just joined
Topic Author
Posts: 2
Joined: Tue Mar 11, 2014 12:19 am

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

Wed Mar 12, 2014 2:28 am

that was it, many thanks
 
jsturm
just joined
Posts: 1
Joined: Mon Jul 06, 2015 10:53 am

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

Mon Jul 06, 2015 11:00 am

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?
 
npongracic
just joined
Posts: 3
Joined: Wed May 18, 2016 1:27 am

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

Wed May 18, 2016 8:36 am

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.
 
gszpiniak
just joined
Posts: 16
Joined: Mon Oct 25, 2010 9:52 pm
Location: Barcelona

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

Tue Jun 14, 2016 11:10 am

Marco, could you please show us your last source code to set the SSID?.