i have followed the following tut
Danny Herran[
^]
here is my code
controller
home.php
<?php
ini_set("display_errors","1");
class Home extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('Facebook_model');
$this->load->library('session');
}
function index()
{
$fb_data = $this->session->userdata('fb_data');
if((!$fb_data['uid']) or (!$fb_data['me']))
{
redirect('login');
}
else
{
$data = array(
'fb_data' => $fb_data,
);
$this->load->view('home', $data);
}
}
}
?>
model
facebook_model.php
<?php
class Facebook_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$config=array(
'appId' => '828846557141612',
'secret' => '7913e12f9a5d746f10a35c5c176cce42',
'fileUpload' => true,
);
$this->load->library('Facebook',$config);
$user=$this->facebook->getUser();
$profile = null;
if($user)
{
try
{
$profile=$this->facebook->api('/me?fields=id,name,link,email');
}
catch(FacebookApiException $e)
{
error_log($e);
$user = null;
}
}
$fb_data=array(
'me' => $profile,
'uid' => $user,
'loginUrl' => $this->facebook->getLoginUrl(
array(
'scope' => 'email,user_birthday,publish_stream',
'redirect_uri' => 'http://tawrny.com/demo/jobs/'
)
),
'logoutUrl' => $this->facebook->getLogoutUrl(),
);
$this->session->set_userdata('fb_data', $fb_data);
}
}
?>
view
home.php
Please login with your FB account: <a href="<?php echo $fb_data['loginUrl']; ?>">login</a>
<div class="fb-login-button" data-show-faces="false" data-width="100" data-max-rows="1" data-scope="email,user_birthday,publish_stream"></div>
<img class="pic" alt="" src="https://graph.facebook.com/<?php echo $fb_data['uid']; ?>/picture" />
Hi ,
<a href="<?php echo site_url('topsecret'); ?>">You can access the top secret page</a> or <a href="<?php echo $fb_data['logoutUrl']; ?>">logout</a>
when i navigate to my site url the following shown
This webpage has a redirect loop
and no thing happens