2017-04-26 13 views
1

에 모바일 와이파이 연결을 끊 : 때, 그러나유니 파이 외부 웹 포털 내가이 라이브러리를 사용하여 유니 파이 컨트롤러 (v5.4.11)에 외부 캡 티브 포털을 만들어 성공적으로 인증 된 장치 한 인증

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

을 내 PHP 코드에서 authorize_guest ($ mac, $ duration) 명령을 보내면 해당 모바일 장치의 WiFi가 실제로 연결이 끊어졌습니다.

이것은 내가 알 수있는 한 Android와 iOS에서 모두 발생합니다. REPO의

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

답변

0

작성자 나에게 응답 : 여기

내가 사용하고있는 코드입니다. 몇 줄은 불필요했다. 작동 코드는 다음과 같습니다.

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