[eluser]jacobson[/eluser]
earlier i had it on my index page only :
Code:
function __construct() {
parent::__construct();
$CI = &get;_instance();
$CI->config->load('facebook', TRUE);
$config = $CI->config->item('facebook');
$this->load->library('Facebook', $config);
}
Code:
public function index() {
$user = null;
$user_profile = null;
$user = $this->facebook->getUser();
if ($user) {
try {
$user_profile = $this->facebook->api('/me');
$facebook_id = $user_profile['id'];
$exists = $this->db->where('facebook_id', $facebook_id)->from('users')->count_all_results();
if ($exists == 0) {
$first_name = $user_profile['first_name'];
$last_name = $user_profile['last_name'];
$link = $user_profile['link'];
$this->site_model->addUser($facebook_id, $first_name, $last_name, $link);
}
} catch (FacebookApiException $e) {
$user = null;
}
}
$data['facebook'] = $this->facebook;
$data['user'] = $user;
$data['user_profile'] = $user_profile;
$data['news'] = $this->site_model->getNews();
$data['main_content'] = 'main';
$this->load->view('includes/template', $data);
}
but I want to have it on all pages that's why I wanted to extend the controller.