How to use Omada api to authorize pending client?

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

How to use Omada api to authorize pending client?

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
How to use Omada api to authorize pending client?
How to use Omada api to authorize pending client?
2022-06-06 04:03:11 - last edited 2022-06-07 16:21:04
Tags: #omada api
Model: EAP225  
Hardware Version: V4
Firmware Version: 5.0.8

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.

 

 

  0      
  0      
#1
Options

Information

Helpful: 0

Views: 525

Replies: 0

Tags

omada api