haloo evry body
i need show user and active users for hotspot
iam try by this code but not work
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
$util = new RouterOS\Util($client = new RouterOS\Client('8.8.8.2', 'admin', ''));
$printRequest = new RouterOS\Request('/ip/hotspot/active/print');
echo $printRequest
Either the Request must be sent using Client, or you could use Util’s methods. You have everything ready, just haven’t actually asked the router.
Using Util f.e.
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
$util = new RouterOS\Util($client = new RouterOS\Client('8.8.8.2', 'admin', ''));
$activeUsers = $util->setMenu('/ip/hotspot/active')->getAll();
//Display the usernames of each active user
foreach ($activeUsers as $user) {
echo $user('name'), '\n';
}
iam edit code
now it’s work
but i cant get hotspot user
ineed get user limit-bytes-total
$activeUsers = $util->setMenu('/ip/hotspot/active')->getAll();
//Display the usernames of each active user
foreach ($activeUsers as $user) {
echo $user('user');
$userlimit = $util->setMenu('/ip/hotspot/user/')->getAll();
foreach ($userlimit as $xxx){
echo $xxx('limit-bytes-total');}
Oh, right… “user”, not “name”. I keep forgetting which menu has which property name… And yeah, I used single quotes when I should’ve used double (which would’ve created a few new lines in the output), sorry.
The “/ip hotspot user” menu is for all users (and that’s where the property is called “name”), while “/ip hotspot active” is for all “active” (as in, “logged in”) users. If you’re trying to read data from there, that’s the only menu you should be reading out of. The limit-bytes-out should be readable from there if you add the “stats” argument, i.e.
$activeUsers = $util->setMenu('/ip/hotspot/active')->getAll(array('stats'));
//Display the username and limit-bytes-total of each active user
foreach ($activeUsers as $user) {
echo $user('user') . ' - ' . $user('limit-bytes-total') . ";\n";
}
(or if that doesn’t work, try to replace “stats” with “detail”)