how can get download and upload of user's with Mikrotik API PHP

Hi, my name is Cristian, i need get download and upload of the user’s with php API of Milkrotik, sorry my english, my lenguage is Spanish…

Hi Christian.

Are we talking hotspot, pppoe, user manager, simple queues? Are we talking “download and upload” as in “speed”, or as in “amount of data”?

Sorry, talking user manager and “amount of data”. Thanks

OK.

With the API client from my signature:

<?php
use PEAR2\Net\RouterOS;

require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';

$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));

foreach ($util->setMenu('/tool user-manager user')->getAll(array('detail')) as $user) {
    echo 'User ' . $user('name') .
        ' has downloaded ' . $user('download-used') .
        ' bytes and has uploaded ' . $user('upload-used') .
        " bytes.\n";
} 

i have with routeros_api

$API = new routeros_api();
$API->debug = false;
if ($API->connect($ipRouteros , $Username , $Pass, $api_puerto)) {
//$API->comm(“/tool/user-manager/user/print/follow”);
//echo var_dump($API);


$API->write(‘/tool/user-manager/user/print’);

$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);

print_r($ARRAY);


}
$API->disconnect();


how get for one user? i can’t get.

i have with routeros_api

Would you consider switching?

If you already have an application, I’ll be happy to migrate it for you, for free. Just send me your code in some fashion (an archive, a git repository… whatever form you choose), and I’ll send you back the migrated one.

how get for one user? i can’t get.

For a specific user, you need to add a query identifying the user.

With this menu in particular (and in general, when items have a “name”), you should also be able to supply the username in the “from” argument of “print”, so for example, to get details on user with username “user1”:

<?php
use PEAR2\Net\RouterOS;

require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';

$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));

foreach ($util->setMenu('/tool user-manager user')->getAll(array('detail', 'from' => 'user1')) as $user) {
    echo 'User ' . $user('name') .
        ' has downloaded ' . $user('download-used') .
        ' bytes and has uploaded ' . $user('upload-used') .
        " bytes.\n";
} 

Very thanks my friend!