Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- require APPPATH . '/libraries/REST_Controller.php';
- class History extends REST_Controller
- {
- function __construct($config = 'rest') {
- parent::__construct($config);
- $this->load->database();
- $this->load->model('HistoryModel');
- }
- public function api_get() {
- $headers = $this->input->request_headers();
- if (array_key_exists('Authorization', $headers) && !empty($headers['Authorization'])) {
- $decodedToken = AUTHORIZATION::validateToken($headers['Authorization']);
- if ($decodedToken != false) {
- if($id_user = $this->uri->segment(3)){
- $response = $this->HistoryModel->getHistory($id_user);
- }else{
- $response['message'] = "User Not Found";
- $response['error'] = true;
- }
- $this->set_response($response,REST_Controller::HTTP_OK);
- }
- }else{
- $this->set_response("Unauthorised", REST_Controller::HTTP_UNAUTHORIZED);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement