Created
June 3, 2009 14:06
-
-
Save philsturgeon/123003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require(APPPATH.'/libraries/REST_Controller.php'); | |
class Example_api extends REST_Controller { | |
function user_get() | |
{ | |
//$user = $this->some_model->getSomething( $this->get('id') ); | |
$user = array('id' => $this->get('id'), 'name' => 'Some Guy', 'email' => '[email protected]'); | |
if($user) | |
{ | |
$this->response($user, 200); // 200 being the HTTP response code | |
} | |
else | |
{ | |
$this->response(NULL, 404); | |
} | |
} | |
function user_delete() | |
{ | |
//$this->some_model->deletesomething( $this->get('id') ); | |
$message = array('id' => $this->get('id'), 'message' => 'DELETED!'); | |
$this->response($message, 200); // 200 being the HTTP response code | |
} | |
function users_get() | |
{ | |
//$users = $this->some_model->getSomething( $this->get('limit') ); | |
$users = array( | |
array('id' => 1, 'name' => 'Some Guy', 'email' => '[email protected]'), | |
array('id' => 2, 'name' => 'Person Face', 'email' => '[email protected]'), | |
array('id' => 3, 'name' => 'Scotty', 'email' => '[email protected]'), | |
); | |
if($users) | |
{ | |
$this->response($users, 200); // 200 being the HTTP response code | |
} | |
else | |
{ | |
$this->response(NULL, 404); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment