I searched here and in the web for my problem, but i didn't found any soluation, this make me crazy, i don't know whats the proplem. the propble is, getUser() function always return 0.
here the my library:
include(APPPATH.'libraries/facebook.php');
class Fbconnect extends Facebook{
public $user_id = null;
public $user = null;
function Fbconnect(){
$ci =& get_instance();
$ci->load->config('facebook',true);
$config = $ci->config->item('facebook');
parent::__construct($config);
$this->user_id = $this->getUser();
$me = null;
if($this->user_id){
try{
$me = $this->api('/me');
$this->user = $me;
}catch(FacebookApiException $e){
error_log($e);
}
}
}
}
and this is the controller
function facebookRequest(){
$this->load->library('fbconnect');
$data = array(
'redirect_uri' => base_url().'home/handleFacebookRequest',
'scope' => 'email'
);
redirect($this->fbconnect->getLoginUrl($data));
}
function handleFacebookRequest(){
$this->load->library('fbconnect');
if($this->fbconnect->user){
echo '<pre>';
print_r($this->fbconnect->user);
}else{
echo "Login operation faild, try again later";
}
}
and i used a config file to store the appId and secrect
$config = array(
'appId' => 'xxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxx',
'cookie' => true
);