【问题标题】:UniFi External Captive Portal - Mobile WiFi Disconnects on AuthUniFi 外部强制网络门户 - 身份验证时移动 WiFi 断开连接
【发布时间】:2017-04-26 19:36:39
【问题描述】:

我在 UniFi 控制器 (v5.4.11) 上创建了一个外部强制门户,并使用此库成功授权设备:

https://github.com/malle-pietje/UniFi-API-browser

但是,当我的 PHP 代码发送 authorize_guest($mac, $duration) 命令时,相关移动设备的 WiFi 实际上已断开连接。

据我所知,这在 Android 和 iOS 上都会发生。

这是我正在使用的代码:

 $controlleruser = $CFG->unifi_user;
$controllerpassword = $CFG->unifi_pass;
$controllerurl = 'https://'.$server.':'.$CFG->unifi_port;
$controllerversion = '5.4.11';
$cookietimeout = '3600';
$theme = 'bootstrap';
$debug = false;
$duration = $CFG->unifi_minutes;
$note = '';
$site_id = 'default';

require_once('class.unifi.php');

$unifidata      = new unifiapi($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
$set_debug_mode = $unifidata->set_debug($debug);
$loginresults   = $unifidata->login();
/**
 * To add note to a new device we need to do the following before authorizing the device:
 * - first block the device to get an entry in the user collection
 * - get the device id from the user collection
 * - add note to the device
 * - then unblock the device again
 */
$block_result   = $unifidata->block_sta($mac);
$getid_result   = $unifidata->stat_client($mac);
$user_id        = $getid_result[0]->_id;
$note_result    = $unifidata->set_sta_note($user_id, $note);
$unblock_result = $unifidata->unblock_sta($mac);
/**
 * then we authorize the device for the requested duration
 */
$auth_result = $unifidata->authorize_guest($mac, $duration);
/**
 * provide feedback in json format
 */
return $auth_result;

【问题讨论】:

    标签: php android curl wifi captiveportal


    【解决方案1】:

    repo 的创建者回复了我。几行是不必要的。工作代码如下所示:

    $unifidata      = new unifiapi($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
    $set_debug_mode = $unifidata->set_debug($debug);
    $loginresults   = $unifidata->login();
    
    $auth_result = $unifidata->authorize_guest($mac, $duration);
    return $auth_result;
    

    【讨论】:

      猜你喜欢
      • 2022-07-11
      • 2014-06-26
      • 1970-01-01
      • 2017-03-30
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 2021-01-31
      • 1970-01-01
      相关资源
      最近更新 更多