所以我有这个代码
<?php
require('routeros_api.class.php');
include 'include/global.php';
include 'include/function.php';
$username = $_GET['user'];
$sql = "SELECT user_macaddress FROM demo_user WHERE user_name='".$username."'";
$result1 = mysql_query($sql);
$mac = mysql_fetch_array($result1);
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('192.168.88.1', 'admin', '1')) {
$API->write('/ip/hotspot/ip-binding/add',false);
$API->write('=type=bypassed',false);
$API->write("=mac-address='".$mac."'",true);
$READ = $API->read();
$API->disconnect();
ob_clean();
header("location:http://google.com");
}
?>我使用php api for mikrotik自动添加mac地址,但mac地址从未显示在winbox中的ip绑定中。你们能帮我吗?
发布于 2017-03-22 01:28:38
请勿将MAC地址括在单引号中。使用以下代码:
$API->write('/ip/hotspot/ip-binding/add',false);
$API->write('=type=bypassed',false);
$API->write('=mac-address='.$mac,true);MAC可以采用以下格式:xx:xx:xx:xx:xx:xx或xxxxxxxxxxxx。
https://stackoverflow.com/questions/42817106
复制相似问题