I want to send http header to Api and get json response.
I have all book detail in books table and I want to get all books.
But i have 5 http header to get access them.
Client-Service,Auth-Key,Content-Type,User-ID,Authorization
Url to get details:
http://127.0.0.1/RestApi/index.php/book/
Controller Code:
public function index() {
$method = $_SERVER['REQUEST_METHOD'];
if ($method != 'GET') {
json_output(400, array('status' => 400, 'message' => 'Bad request.'));
} else {
$check_auth_client = $this->MyModel->check_auth_client();
if ($check_auth_client == true) {
$response = $this->MyModel->auth();
if ($response['status'] == 200) {
$resp = $this->MyModel->book_all_data();
json_output($response['status'], $resp);
}
}
}
}
Model Code:
public function book_all_data()
{
return $this->db->select('id,title,author')->from('books')->order_by('id','desc')->get()->result();
}
I want to access to access on button click but how send http header to rest api page and get all data using codeigniter ?