PHP code example of jauhar / router-api

1. Go to this page and download the library: Download jauhar/router-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jauhar / router-api example snippets




nologi\RouterApi\Core;
use Jnologi\RouterApi\RestApi;

$api = Core::config('{ip_router}', '{username}', '{password}');

$api->setPort('{set_port_mikrotik}') // default-nya 8728

$response = $api->query('/interface/print');
print_r($response);

//  Metode pakai RestFullAPI
$rest = RestApi::init('{ip_router}', '{username}', '{password}');
$rest->setPort('{your_mikrotik_port}') // Defaultnya 80

$resultApi = $rest->get('{url}') // Metode GET
$resultApi = $rest->add('{url}', $data) // Metode PUT
$resultApi = $rest->update('{url}', $data) // Metode PATCH
$resultApi = $rest->delete('{url}') // Metode DELETE

echo "<pre>";
print_r($resultApi);
echo "</pre>";



$response = $api->where('/interface/print', [
    '?name' => 'ether1'
]);

print_r($response);

  $api->where('/interface/monitor-traffic', [
    '?interface' => 'ether1',
    '?once' => true
  ]);