1

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;
4

1 に答える 1