Search Results

Search found 1 results on 1 pages for 'zeekerg'.

Page 1/1 | 1 

  • Rest API Web Service - iOS

    - by zeekerg
    Its my first time to use web service in iOS. REST was my first choice and I use code igniter to form it. I have my Controller: require APPPATH.'/libraries/REST_Controller.php'; class Sample extends REST_Controller { function example_get() { $this->load->helper('arh'); $this->load->model('users'); $users_array = array(); $users = $this->users->get_all_users(); foreach($users as $user){ $new_array = array( 'id'=>$user->id , 'name'=>$user->name, 'age'=>$user->age, ); array_push( $users_array, $new_array); } $data['users'] = $users_array; if($data) { $this->response($data, 200); } } function user_put() { $this->load->model('users'); $this->users->insertAUser(); $message = array('message' => 'ADDED!'); $this->response($message, 200); } } , using my web browser, accessing the URL http://localhost:8888/restApi/index.php/sample/example/format/json really works fine and gives this output: {"users":[{"id":"1","name":"Porcopio","age":"99"},{"id":"2","name":"Name1","age":"24"},{"id":"3","name":"Porcopio","age":"99"},{"id":"4","name":"Porcopio","age":"99"},{"id":"5","name":"Luna","age":"99"}]} , this gives me a great output using RKRequest by RestKit in my app. The problem goes with the put method. This URL : http://localhost:8888/restApi/index.php/sample/user always give me an error like this: This XML file does not appear to have any style information associated with it. The document tree is shown below. <xml> <status/> <error>Unknown method.</error> This is my Users model <?php class Users extends CI_Model { function __construct() { parent::__construct(); } function get_all_users() { $this->load->database(); $query = $this->db->get('users'); return $query->result(); } function insertAUser(){ $this->load->database(); $data = array('name'=> "Sample Name", 'age'=>"99"); $this->db->insert('users', $data); } } ?> What is the work around for my _put method why am I not inserting anything? Thanks all!

    Read the article

1