i am trying to read file contents through PHP API but i am a little bit confused.
I want to get a string with numbers from a file called test.txt but i can’t so far.
<?php
require('routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = false;
if ($API->connect('192.168.10.1', 'alfa', 'beta')) { // Change this as necessery
$API->write('/file/get/test.txt/contents');
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
}
?>
relpy
Array
(
[!trap] => Array
(
[0] => Array
(
[message] => no such command prefix
)
)
)
Also, i am wondering if i can get this value from a global variable and not from the file, is this possible?
I am sorry to say that but i don’t know nothing about PHP. I can easily do things in CLI but i cannot translate them in the PHP format. Your CLI works like a charm! And your php code as well!
Just to inform, to access a global variable from API, user should have full access privilege and not just ‘read’. With read only access, you get a permission error!