创建受保护的 API

公共用户无法访问此 API,因此需要进行身份验证

/***************************
this is protected api this is not accessible if you are not loged in
***************************/
public function protectedapi(){
  if($this->session->userdata('logged_in')){
    //this section only accessible when user loged in
    $this->output->set_output(json_encode(array('status'=>true,'msg'=>'Access allowed')));
  }else{
    $this->output->set_output(json_encode(array('status'=>true,'msg'=>'Access denied')));
  }
}

https://i.stack.imgur.com/e42MM.jpg