How to use Omada api to authorize pending client?
Hi,
I'm trying to authorize client true Omada api.
i used the docs : faq 3231
function login() {
$loginInfo = array(
"name" => $this->user,
"password" => $this->pass
);
$headers = array(
"Content-Type: application/json",
"Accept: application/json"
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->path );
curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->path );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
curl_setopt( $ch, CURLOPT_URL, $this->controller . "/" . $this->cid . " . "/api/v2/hotspot/login" );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $loginInfo ) );
$res = curl_exec( $ch );
$resObj = json_decode( $res );
if ( $res && $resObj->errorCode == 0 ) {
$this->setCSRFToken($resObj->result->token);
return TRUE;
} else {
return FALSE;
}
}
So i got the cookie token, and then try to authorize :
function authorize($clientMac, $apMac, $ssidName, $radioId, $milliseconds, $site)
{
$authInfo = array(
'clientMac' => $clientMac,
'apMac' => $apMac,
'ssidName' => $ssidName,
'radioId' => $radioId,
'time' => $milliseconds,
'site' => $site,
'authType' => 4
);
$csrfToken = $this->getCSRFToken();
$headers = array(
'Content-Type: application/json',
'Accept: application/json',
'Csrf-Token: ' . $csrfToken
);
$url=$this->controller . "/" . $this->cid . "/api/v2/hotspot/login";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($authInfo));
$res = curl_exec($ch);
$resObj = json_decode($res);
if ($res && $resObj->errorCode == 0) {
return TRUE;
} else {
return FALSE;
}
curl_close($ch);
}
so here what i do :
if(!$this->login()){
return FALSE;
} elseif(!$this->authorize($clientMac, $apMac, $ssidName, $radioId, $milliseconds, $site)) {
return FALSE;
} else {
return TRUE;
}
but the result is always NULL. Nor error nor success just a null result when i check the curl result of authorize function.
is someone facing the same problem?
I tried the documentation Omada_SDN_Controller_V5.0.15 API Document.zip but same thing.
help plz.