1

I want to retrieve the mikrotik PPPoE server service name list by using the mikrotik API and loop through all of the service names over a select menu. I have done the code myself. The code looks like below:

$ctype =$this->uri->segment('3');
if($ctype=='PPP')
{
  if ($this->routerosapi->connect('1.1.1.1', 'xxx', 'xxx')) 
  {
    $this->routerosapi->write('/interface/pppoe-server/getall');
    $READ = $this->routerosapi->read(false);
    $mktserver= $this->routerosapi->parseResponse($READ);  
    $this->routerosapi->disconnect();
  }
}
elseif($ctype=='HSP')
{
  if ($this->routerosapi->connect('xxx', 'xxx', 'xxx')) 
  {
    $this->routerosapi->write('/ip/hotspot/server/getall');
    $READ = $this->routerosapi->read(false);
    $mktserver= $this->routerosapi->parseResponse($READ);  
    $this->routerosapi->disconnect();
  }
}  
<p>
    <label for="simple-required">Server</label>
    <select name="server" id="server" class="full-width">
    <?php foreach($mktserver as $item):?>
    <option value="<?php echo $item['service-name'];?>"><?php echo $item['service-name'];?></option>
    <?php endforeach;?>
</select>
</p>

What am I doing wrong?

Note:
Please be specific on your answer. I don't want any basic answer. I want you to read the code very carefully and understand it and finally answer it. For your concern I want both list iteration of PPPoE and Hotspot of Mikrotik.

Artemij Rodionov
  • 1,721
  • 1
  • 17
  • 22

1 Answers1

0

At the risk of giving a "basic" answer, please see this mikrotik cli command:

:put [/interface get [find type=pppoe-out]]

I suggest getting the command you want to work to work fine in the cli before attempting to do it in the api..

user230910
  • 2,353
  • 2
  • 28
  • 50