title: How to fix "Call to a member function getUser()" in facebook via CodeIgniter?
body: <p>I am sitting in my chair for 2 hours and I cannot find what is wrong with this. I'm new to codeigniter things and I only got this error for the first time. Can you guys help me? Any help would be appreciated. Thanks in advance so much ...</p>
  
  <pre><code>****A PHP Error was encountered
  Severity: Notice
  Message: Undefined property: Facebook_model::$facebook
  Filename: models/facebook_model.php
  Line Number: 15
  Fatal error: *Call to a member function getUser() on a non-object in C:\xampp\htdocs\hpbge\hpbge_files\system\hpbgestrong text_web_app\models\facebook_model.php on line 15*****
  
  
  &lt;?php
  </code></pre>
  
  <p>class Facebook_model extends Model {</p>
  
  <pre><code>public function get_user() {
  
      $query = $this-&gt;facebook-&gt;getUser();
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          $data['facebook_uid'] = $query;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function get_access_token() {
  
      $query = $this-&gt;facebook-&gt;getAccessToken();
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          $data['access_token'] = $query;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function get_api_secret() {
  
      $query = $this-&gt;facebook-&gt;getApiSecret();
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          $data['api_secret'] = $query;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function get_app_id() {
  
      $query = $this-&gt;facebook-&gt;getApiSecret();
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          $data['app_id'] = $query;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function get_logout_url() {
  
      $query = $this-&gt;facebook-&gt;getLogoutUrl(array('next' =&gt; base_url()));
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          $data['logout_url'] = $query;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function get_signed_request() {
  
      $query = $this-&gt;facebook-&gt;getSignedRequest();
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          $data['signed_request'] = $query;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function set_access_token($access_token) {
  
      $query = $this-&gt;facebook-&gt;setAccessToken($access_token);
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function set_api_secret($app_secret) {
  
      $query = $this-&gt;facebook-&gt;setApiSecret($app_secret);
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  function set_app_id($app_id) {
  
      $query = $this-&gt;facebook-&gt;setAppId($app_id);
  
  
  
      if ($query) {
  
          $data['is_true'] = TRUE;
  
          return $data;
  
      } else {
  
          $data['is_true'] = FALSE;
  
          return $data;
  
      }
  
  }
  
  
  
  //function is formatted for the following
  
  //https://graph.facebook.com/ID/CONNECTION_TYPE?access_token=123456
  
  function get_facebook_object($object, $facebook_uid, $access_token) {
  
      $fb_connect = curl_init();  
  
      curl_setopt($fb_connect, CURLOPT_URL, 'https://graph.facebook.com/'.$facebook_uid.'/'.$object.'?access_token='.$access_token);  
  
      curl_setopt($fb_connect, CURLOPT_RETURNTRANSFER, 1);  
  
      $output = curl_exec($fb_connect);  
  
      curl_close($fb_connect);  
  
  
  
      $result = json_decode($output);
  
  
  
      if (isset($result-&gt;error)) {
  
          $data['is_true'] = FALSE;
  
          $data['message'] = $result-&gt;error-&gt;message;
  
          $data['type'] = $result-&gt;error-&gt;type;
  
          $data['code'] = $result-&gt;error-&gt;code;
  
  
  
          return $data;
  
      } else {
  
          $data['is_true'] = TRUE;
  
          $data['data'] = $result-&gt;data;
  
  
  
          return $data;
  
      }
  
  }   
  </code></pre>
  
  <p>}</p>