Page 1 of 1

PHP API write question

Posted: Wed Nov 26, 2008 3:37 pm
by cieplik206
Hello

I am trying a PHP API class. works great. i can read all, but how to write?

For example how to set IP address on certain interface ?

I tried
$API->write('/ip/address/add=address=6.6.6.6=netmask=255.255.255.0=interface=bridge_hotspot');

as well as
$API->write('/ip/address/add');
$API->write('=address=6.6.6.6');
$API->write('=netmask=255.255.255.0');
$API->write('=interface=bridge_hotspot');
and everytime i am getting response

>>> [24, 8] =message=no such command

any hint ?

Re: PHP API write question

Posted: Wed Nov 26, 2008 3:46 pm
by mrz
There is no parameter as netmask .
Use:
/ip/address/add
=address=6.6.6.6/24
=interface=bridge_hotspot

Re: PHP API write question

Posted: Wed Nov 26, 2008 4:49 pm
by cieplik206
There is no parameter as netmask .
Use:
/ip/address/add
=address=6.6.6.6/24
=interface=bridge_hotspot
Should i send it as one string or using 3 diffrent API->write methods ?

just ried it.. and didnt work neither

EDIT

ok i forgot to add second argument of that method
$API->write('/ip/address/add',false);
$API->write('=address=6.6.6.6/24',false);
$API->write('=interface=bridge_hotspot');

Re: PHP API write question

Posted: Wed Jan 09, 2019 5:32 pm
by frank0000
I'm new to using the routeros api and I'm working on an application that I didn't initially build that uses the routeros api to manipulate MikroTik Routers. So I have three questions:
Where can I find helpful documentation for the api?
In the previous comments, it gets mentioned that you need a second parameter of either true or false for the write command. When should I use false and when I use true?
And finally, right now the main question I need answered is how do I use the API to simply execute an existing script that already resides in system/scripts in the MiktriTik Router?

Through the routeros terminal I can execute the script with "/system script run Script_Name". But I don't know how to accomplish this through the API.