I am implementing the facebook connect and its working partially well for me. Its successfully loging the user when some login in with facebook. Here is the link for login http://beta-demo.info/party/users/loginByFacebook but after login when i am trying to fetch user detail from facebook its now displaying anything.
Here is the code of of Fb_Connect.php This file is placed in Libraries folder
<?php
include(APPPATH.'libraries/facebook/facebook.php');
class Fb_connect extends Facebook{
//declare public variables
public $user = NULL;
public $user_id = FALSE;
public $fb = FALSE;
public $fbSession = FALSE;
public $appkey = 0;
//constructor method.
public function __construct()
{
$CI = & get_instance();
$CI->config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
parent::__construct($config);
$this->user_id = $this->getUser(); // New code
$me = null;
if ($this->user_id) {
try {
$me = $this->api('/me');
$this->user = $me;
} catch (FacebookApiException $e) {
error_log($e);
}
}
}
} // end class
and this is loging function
function loginByFacebook(){
$this->load->library('fb_connect');
$param['redirect_uri']=base_url();
redirect($this->fb_connect->getLoginUrl($param));
}
and this is the info function where i am trying to fetch the value.
function facebook() {
print('<pre>');
print_r($this->fb_connect);
if (!$this->fb_connect->user_id) {
echo 'No working ';
//Handle not logged in,
} else {
echo $fb_uid = $this->fb_connect->user_id;
echo $fb_usr = $this->fb_connect->user;
//Hanlde user logged in, you can update your session with the available data
//print_r($fb_usr) will help to see what is returned
}
}
Url of the info page http://beta-demo.info/party/users/facebook
I dont have much of idea about facebook connect API.so please help me
This is the working code for me