-
StackOverflow 文件
-
codeigniter 教程
-
在 Codeigniter 中建立 API
-
建立受保護的 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