Hi,
- We have Created System using CodeIgniter 2.2.0
- Now we wants to Apply REST
1. Is it possible to Apply REST with CodeIgniter 2.2.0 , If yes than How ?
Other Option,
- We have Working with PHP 5.4 version as Rerquired for Applying REST
- We will upgrade CodeIgniter 2.2.0 to CodeIgniter 3.0
- We have Applied REST Server From below link :
https://github.com/chriskacerguis/codeig...restserver
1. Is it possible to call CI_Controller in REST_Controller ?
2. How to pass Value from REST_Controller to CI_Controller ?
- I want to create Simple Login System Using CodeIgniter 3.0 with REST
I have applied below code for login :
Code:
<?php
require APPPATH.'/libraries/REST_Controller.php';
class Login_api_new extends REST_Controller {
function __construct()
{
// Construct our parent class
parent::__construct();
$this->load->library("Session/Session");
// Configure limits on our controller methods. Ensure
// you have created the 'limits' table and enabled 'limits'
// within application/config/rest.php
$this->methods['validate_user_get']['limit'] = 500; //500 requests per hour per user/key
$this->methods['validate_user_post']['limit'] = 100; //100 requests per hour per user/key
}
function validate_user_get()
{
if(!$this->get('username') && !$this->get('password'))
{
$this->response(NULL, 400);
}
else if($this->get('username') && $this->get('password'))
{
$username = $this->get('username');
$pass = $this->get('password');
$this->verify_user($username,$pass);
}
else
{
$this->response(array('error' => 'User could not be found'), 404);
}
}
function validate_user_post()
{
if(!$this->get('username') && !$this->get('password'))
{
$this->response(NULL, 400);
}
else
{
$username = $this->input->post('username');
$pass = $this->input->post('password');
$this->verify_user($username,$pass);
}
$this->response($message, 200); // 200 being the HTTP response code
}
function verify_user($username,$pass)
{
$this->load->library('../controllers/Login');
$result = $this->Login->login_user($username, $pass);
echo "res : ".$result;
}
}
Using above code its display blank page as well as i not getting any session variable. Is it correct way to use REST with login module ?