Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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']))
        {
            // If this is a protected section that needs user authentication
            // you can redirect the user somewhere else
            // or take any other action you need
            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, // Indicates if the CURL
        
        
        
        
        );
        
       

        
        $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', // app permissions
                                'redirect_uri' => 'http://tawrny.com/demo/jobs/' // URL where you want to redirect your users after 
                            )
                        ),
                        'logoutUrl' => $this->facebook->getLogoutUrl(),
         
         
         );
         
         
          $this->session->set_userdata('fb_data', $fb_data);
         
         
         
         
         
    }
    
}


?>


view
home.php

XML
<?php if(!$fb_data['me']): ?>
  Please login with your FB account: <a href="<?php echo $fb_data['loginUrl']; ?>">login</a>
  <!-- Or you can use XFBML -->
<div class="fb-login-button" data-show-faces="false" data-width="100" data-max-rows="1" data-scope="email,user_birthday,publish_stream"></div>
  <?php else: ?>
  <img class="pic" alt="" src="https://graph.facebook.com/<?php echo $fb_data['uid']; ?>/picture" />

Hi <?php echo $fb_data['me']['name']; ?>,

    <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>

  <?php endif; ?>



when i navigate to my site url the following shown
This webpage has a redirect loop
and no thing happens
Posted
Updated 2-Dec-13 0:50am
v4
Comments
CHill60 1-Dec-13 11:19am    
As per you earlier post - you need to use a direct link not redirected.
Also if you have issues with Danny Herran's code you can post comments and questions directly against that blog

1 solution

Do you really think posting the same thing again is going to change the solution?
Let me copy and past the last sentence of my other answer.

Also I am almost 100% sure you need to provide the direct link not a redirecting link.
 
Share this answer
 
Comments
CHill60 1-Dec-13 12:47pm    
My 5 ... for your patience and because I didn't credit you with the solution I mentioned in my comment above
[no name] 1-Dec-13 13:07pm    
i think he is illiterate
TheSniper105 2-Dec-13 6:48am    
the Previously issue was with facebook app setting (App Domains‎) and i already correct the mistake by writting the correct domain tawrny.com and now it's in my script and i can't figure how to solve it so it's not the same thing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900