PEAR2_Net_RouterOS-1.0.0b4PEAR2_Net_RouterOS-1.0.0b4/examples/send-and-complete.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace PEAR2\Net\RouterOS;

require_once 'PEAR2/Net/RouterOS/Autoload.php';

$client = new Client('192.168.0.1', 'admin');

$addRequest = new Request('/ip/arp/add');

$addRequest->setArgument('address', '192.168.0.100');
$addRequest->setArgument('mac-address', '00:00:00:00:00:01');
$addRequest->setTag('arp1');
$client->sendAsync($addRequest);

$addRequest->setArgument('address', '192.168.0.101');
$addRequest->setArgument('mac-address', '00:00:00:00:00:02');
$addRequest->setTag('arp2');
$client->sendAsync($addRequest);

foreach ($client->completeRequest('arp1') as $response) {
    if ($response->getType() === Response::TYPE_ERROR) {
        echo "Error response for 'arp1'!\n";
    }
}

foreach ($client->completeRequest('arp2') as $response) {
    if ($response->getType() === Response::TYPE_ERROR) {
        echo "Error response for 'arp2'!\n";
    }
}

echo 'OK';
EOF