I can be more accurate maybe.. i would like to create a website AND a mobile app that can access the same data
so maybe i could create a very simple (but secure) API (just one user perhaps). Do i have to use oAuth2 for any API? I heard that it's pretty tricky to implement
public function router($resource, array $arguments) {
\Config::load('rest', true);
$this->format = 'json';
// If they call user, go to $this->post_user();
$controller_method = strtolower(\Input::method()) . '_' . $resource;
//is this a valid method
if (method_exists($this, $controller_method)) {
if ($controller_method == 'post_login') {
call_user_func_array(array($this, 'post_login'), $arguments);
} else {
$session_key = Input::post('session_key');
$session = Model_Session::find()
->where('session_key', $session_key)
->get_one();
if (!$session) {
$this->response(array('status' => 0, 'error' => 'Not Authorized'), 401);
return;
} else {
call_user_func_array(array($this, $controller_method), $arguments);
}
}
} else {
$this->response(array('status' => 0, 'error' => 'Invalid method'), 405);
return;
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!