PHP API get RX etc.

Hi,
how I can get via API rx/tx info?

I use http://wiki.mikrotik.com/wiki/API_PHP_class.

I tried this, but displays only the name. What’s wrong?

<?php

require('routeros_api.class.php');

$API = new routeros_api();

$API->debug = false;

if ($API->connect('1.0.0.101', '0', '0')) {   // Change this as necessery

$ARRAY = $API->comm('/interface/print');
$ARRAY2 = $API->comm('/interface/print stats-detail from 0');
$ARRAY3 = $API->comm('/interface/monitor-traffic "Port 1 - WAN"');
   
$first = $ARRAY['0'];
$second = $ARRAY2['0'];
$third = $ARRAY3['0'];
  
echo "name: " . $first['name'] . " <br />";
echo "rx-byte: " . $second['rx-byte'] . " <br />";
echo "rx-bits-per-second: " . $third['rx-bits-per-second'] . " <br />";

$API->disconnect();

}

?>

With most clients, arguments must be written separately from the command, whereas you’re writing them together. This results in an error response from RouterOS. You’re not testing if what you’re getting is an error, so trying to display something that is not there simply displays nothing.

Also, nameless arguments are not supported in API - you must explicitly write all argument names.

With my client, only the last requirement is still there. If you insist on using this client… I believe the comm() function accepts arguments to the command as a second argument that is an array, i.e.

$ARRAY = $API->comm('/interface/print');
$ARRAY2 = $API->comm('/interface/print', array('stats-detail' => '', 'from' => '0'));
$ARRAY3 = $API->comm('/interface/monitor-traffic', array('interface'=>"Port 1 - WAN"));