Page 1 of 1

[API] Php + for/while issues

Posted: Tue Oct 06, 2009 12:40 pm
by jalokim
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();
}

Re: [API] Php + for/while issues

Posted: Tue Oct 06, 2009 2:09 pm
by janisk
if ($API->connect('', ', ''))

don't you need some arguments there?

Re: [API] Php + for/while issues

Posted: Thu Oct 08, 2009 2:04 am
by jalokim
ofc :) but i think that i shouldn't give ip, user and pass;)

Re: [API] Php + for/while issues

Posted: Mon Oct 26, 2009 9:44 pm
by mwarren77
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.

Re: [API] Php + for/while issues

Posted: Sun Nov 01, 2009 2:45 pm
by kozmai
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?

Re: [API] Php + for/while issues

Posted: Mon Nov 02, 2009 7:18 pm
by kozmai
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.