【问题标题】:How to retrieve the mikrotik PPPoE server service name list by using the mikrotik API?如何使用 mikrotik API 检索 mikrotik PPPoE 服务器服务名称列表?
【发布时间】:2019-01-26 21:09:54
【问题描述】:

我想通过使用 mikrotik API 检索 mikrotik PPPoE 服务器服务名称列表,并通过选择菜单遍历所有服务名称。我自己完成了代码。代码如下所示:

$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>

我做错了什么?

注意:
请具体回答。我不想要任何基本的答案。我希望您非常仔细地阅读代码并理解它并最终回答它。为了您的关注,我想要 PPPoE 的列表迭代和 Mikrotik 的热点。

【问题讨论】:

    标签: hotspot mikrotik pppoe


    【解决方案1】:

    冒着给出“基本”答案的风险,请查看这个 mikrotik cli 命令:

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

    我建议先让你想在 cli 中正常运行的命令,然后再尝试在 api 中执行。

    【讨论】:

    • 感谢您的回答。但它是一个终端基础答案。我正在寻找基于 php 的答案。
    猜你喜欢
    • 2018-01-06
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    • 2023-01-19
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 1970-01-01
    相关资源
    最近更新 更多