Community discussions

 
cieplik206
Trainer
Trainer
Topic Author
Posts: 286
Joined: Sun Jul 01, 2007 12:25 am
Contact:

PHP API write question

Wed Nov 26, 2008 3:37 pm

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 ?
https://www.wispcasts.com - Mikrotik Video Tutorials.

The best place where you can improve your skills!

Facebook - F/wispcasts
Twitter - @wispcasts
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5933
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: PHP API write question

Wed Nov 26, 2008 3:46 pm

There is no parameter as netmask .
Use:
/ip/address/add
=address=6.6.6.6/24
=interface=bridge_hotspot
 
cieplik206
Trainer
Trainer
Topic Author
Posts: 286
Joined: Sun Jul 01, 2007 12:25 am
Contact:

Re: PHP API write question

Wed Nov 26, 2008 4:49 pm

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');
https://www.wispcasts.com - Mikrotik Video Tutorials.

The best place where you can improve your skills!

Facebook - F/wispcasts
Twitter - @wispcasts
 
frank0000
just joined
Posts: 1
Joined: Thu Nov 08, 2018 7:03 pm

Re: PHP API write question

Wed Jan 09, 2019 5:32 pm

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.

Who is online

Users browsing this forum: No registered users and 10 guests