Accessing the REST Server Using the Rest Client Library

Home

Tests Home

Code Example:

        $user_id = 1;

        $this->load->helper('url');

        $this->load->library('rest_client', array(
            'server' => site_url('api/example/'),
            //'http_user' => 'admin',
            //'http_pass' => '1234',
            //'http_auth' => 'basic' // or 'digest'
        ));

        $result = $this->rest_client->get('users/id/'.$user_id.'/format/json');

Result:

object(stdClass)#31 (2) {
  ["status"]=>
  bool(false)
  ["error"]=>
  string(16) "Invalid API key "
}