Community discussions

MUM Europe 2020
 
jalokim
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 76
Joined: Thu Dec 07, 2006 1:39 pm
Location: PL, Tychy
Contact:

[API] Php + for/while issues

Tue Oct 06, 2009 12:40 pm

Hi,

I'm using API interface on PHP. When I trying to for ex add few ip addresses to ip address list i get in mt log: login error for user api via winbox. When i wait few second and run scrip again it works.

What is anoying is that this working randomly - any ideas?

Script works like that:
if ($API->connect('', ', ''))
{
		for()
		{
			$API->write('/ip/firewall/address-list/add',false);
			$API->write('=list='.$lista,false);
			$API->write('=address='.$ip);
			$odp = $API->read();
		}
		$API->disconnect();
}
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: [API] Php + for/while issues

Tue Oct 06, 2009 2:09 pm

if ($API->connect('', ', ''))

don't you need some arguments there?
 
jalokim
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 76
Joined: Thu Dec 07, 2006 1:39 pm
Location: PL, Tychy
Contact:

Re: [API] Php + for/while issues

Thu Oct 08, 2009 2:04 am

ofc :) but i think that i shouldn't give ip, user and pass;)
 
mwarren77
just joined
Posts: 18
Joined: Tue Oct 20, 2009 10:28 pm

Re: [API] Php + for/while issues

Mon Oct 26, 2009 9:44 pm

If you send me the script I can look at this for you. I would need the whole script and not just your API portion.
 
kozmai
just joined
Posts: 20
Joined: Thu Sep 20, 2007 3:11 pm

Re: [API] Php + for/while issues

Sun Nov 01, 2009 2:45 pm

I have a simple api script in php

$api->write('/interface/wireless/registration-table/print',true);
$array = $api->read();
$api->disconnect();

after I wrote here some code that draws a html table and put data into the table.

The problem is, after $array = $api->read(); command, lot of numbers appear before my table.

Can anybody help me?
 
kozmai
just joined
Posts: 20
Joined: Thu Sep 20, 2007 3:11 pm

Re: [API] Php + for/while issues

Mon Nov 02, 2009 7:18 pm

I have found the problem. There is a command in the read function of routeros_api.class.php file: echo "$BYTE\n";
I have commented and the problem is gone.

Who is online

Users browsing this forum: No registered users and 20 guests