Files
cm-app-services2/application/controllers/api/radio.php

55 lines
1.7 KiB
PHP

<?php defined('BASEPATH') or exit('No direct script access allowed');
require APPPATH . '/libraries/REST_Controller.php';
class Radio extends REST_Controller
{
private $tokenChecked;
public function __construct()
{
parent::__construct();
$this->load->library('RadioService', array(), 'radioService');
$this->tokenChecked = $this->radioService->checkToken();
}
public function index_get()
{
echo 'Invalid Access';
}
public function schedule_get()
{
if (is_null($this->tokenChecked)) {
$this->res(200, 'Success', $this->radioService->getSchedule($this->get('categoryId'), $this->get('day')));
} else if ($this->tokenChecked == 402) {
$this->res(402, 'Token expired');
} else if ($this->tokenChecked == 401){
$this->res(401, 'error');
}
}
public function category_get()
{
if (is_null($this->tokenChecked)) {
$this->res(200, 'Success', $this->radioService->getCategory($this->radioService->getAppId($this->get('appId'))));
} else if ($this->tokenChecked == 402) {
$this->res(402, 'Token expired');
} else if ($this->tokenChecked == 401){
$this->res(401, 'error');
}
}
public function app_get()
{
if (is_null($this->tokenChecked)) {
$this->res(200, 'Success', $this->radioService->getApp($this->radioService->getAppId($this->get('appId'))));
} else if ($this->tokenChecked == 402) {
$this->res(402, 'Token expired');
} else if ($this->tokenChecked == 401){
$this->res(401, 'error');
}
}
}