routeros-api-php icon indicating copy to clipboard operation
routeros-api-php copied to clipboard

new version not working

Open nrtszr opened this issue 2 years ago • 1 comments

Hi,

hotspot user add

// Initiate client with config object
$client = new Client([
    'timeout' => 1,
    'host'    => $ip,
    'user'    => $user_name,
    'pass'    => $password
]);

$hotspot_user_control = $client->query('/ip/hotspot/user/print', ['name', "$hotspot_user"])->read();

if (isset($hotspot_user_control[0]['.id'])) {

    $userId = $hotspot_user_control[0]['.id'];
    echo 'Update';
    $out = $client->write(["/ip/hotspot/user/set","=password=$hotspot_user_pass","=.id=$userId"])->read();
}
else
{
    echo 'New';
    $out = $client->write(['/ip/hotspot/user/add', "=name=$hotspot_user","=password=$hotspot_user_pass",])->read();
}

Remove Hotspot User:

$client = new Client([
    'timeout' => 1,
    'host'    => $ip,
    'user'    => $user_name,
    'pass'    => $password
]);

$user = $client->query('/ip/hotspot/user/print', ['name', $hotspot_user])->read();

if (isset($user[0]['.id'])) {
    $userId = $user[0]['.id'];
    echo $userId;
    echo '<hr>';
    $out = $client->write(["/ip/hotspot/user/remove","=.id=$userId"])->read();
}

new version update don't work

nrtszr avatar Jun 23 '22 17:06 nrtszr

Hello! New version of what? RouterOS? This API client library?

EvilFreelancer avatar Jun 24 '22 03:06 EvilFreelancer