Advertisement
vdp

Untitled

vdp
Jun 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. class History extends REST_Controller
  5. {
  6.     function __construct($config = 'rest') {
  7.       parent::__construct($config);
  8.       $this->load->database();
  9.       $this->load->model('HistoryModel');
  10.     }
  11.     public function api_get() {
  12.         $headers = $this->input->request_headers();
  13.         if (array_key_exists('Authorization', $headers) && !empty($headers['Authorization'])) {
  14.             $decodedToken = AUTHORIZATION::validateToken($headers['Authorization']);
  15.             if ($decodedToken != false) {
  16.               if($id_user = $this->uri->segment(3)){
  17.                 $response = $this->HistoryModel->getHistory($id_user);
  18.               }else{
  19.                 $response['message'] = "User Not Found";
  20.                 $response['error'] = true;
  21.               }
  22.               $this->set_response($response,REST_Controller::HTTP_OK);
  23.             }
  24.         }else{
  25.           $this->set_response("Unauthorised", REST_Controller::HTTP_UNAUTHORIZED);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement