Im trying to apply a rate limit to my hotspot using the PHP PEAR API this is the script i currently have:
$request = “/ip hotspot profile set Hotspot rate-limit=200k/200k”;
$addRequest = new RouterOS\Request($request);
$client->sendSync($addRequest);
It seems like it should work but it isn’t working… is there anyway to add the limit for for every profile?
Best,
Patrick
You need to explicitly add every argument name.
In this case, you’re missing the “numbers” argument, so:
$request = '/ip hotspot profile set numbers=Hotspot rate-limit=200k/200k';
If you want to add the limit to all server profiles (if there is more than one that is…), then it’s easiest to use the Util class instead, e.g.
$util = new RouterOS\Util($client);
$util->changeMenu('/ip hotspot profile');
$util->set($util->find(), array('rate-limit' => '200k/200k'));
The alternative is that you explicitly do what Util does under the hood - make a separate call to “find”, get the “ret” property out of it, and set it as a value for “numbers”.
Brilliant that all worked just as expected. Thank you for your help.
Just to give anyone else an idea of my end code here
$down = $_POST["down"];
$up = $_POST["up"];
$type = $_POST["type"];
$fd = $down."k"; //format down
$fu = $up."k"; //format up
$request = "/ip hotspot user profile set numbers=$type rate-limit=$fu/$fd";
$addRequest = new RouterOS\Request($request);
$client->sendSync($addRequest);