<? class Controller_Api extends Controller_Rest { public $response; private $user_id; private $data; private $success; private $message; private $output; public function before($data = null) { $this->success = false; $this->message = null; $this->output = null; $this->code = 200; $valid_session = false; $api_key = Input::get('api_key'); $session_key = Input::get('session_key'); //do some db logic to determine if a valid sessioin if($valid_session == false){ //send back error and I want to stop here $this->message = 'invalid session'; } return parent::before(); } public function get_something(){ echo "doing something because you have valid credentials"; } public function after() { $this->response(array('success' => $this->success, 'message' => $this->message, 'output' => $this->output), $this->code); return parent::after(); } }
It looks like you're new here. If you want to get involved, click one of these buttons!