System Identity API PEAR2

Hi again :slight_smile:

I tried print a name of my mikrotik router and it returns nothing :S

This is the code:

<?php use PEAR2\Net\RouterOS; // require_once 'pear2\src\PEAR2\Autoload.php'; require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar'; $client = new RouterOS\Client('xx.xxx.xx.xxx', 'victor', 'xxxxx'); $cabecera = new RouterOS\Request('/system/identity/print'); return $cabecera('name'); ?>

You need to actually send the request. $cabecera merely contains a description of what you’d eventually be sending (command, arguments, etc.).

To send a request, you use $client, and it’s sendSync() or sendAsync() method in particular, and give it the request, which will then be sent.

Also, “return” works within a function/method or an included file. If you want to print it on screen directly, you’d want to use “echo” insted.

E.g.

<?php use PEAR2\Net\RouterOS; // require_once 'pear2\src\PEAR2\Autoload.php'; require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar'; $client = new RouterOS\Client('xx.xxx.xx.xxx', 'victor', 'xxxxx'); $cabecera = new RouterOS\Request('/system/identity/print'); $cabecera_result = $client->sendSync($cabecera); echo $cabecera_result('name'); ?>