rash111
rash111

Reputation: 1317

how to log in with facebook using codeigniter

1.what is basic step for login with Facebook, when user log in with Facebook how its information is accessed from Facebook. how to redirect after successful login.

2.when first time user log in then we take information of that user, what is the process of next login i.e we have information of that user when user log in with first time then what is the process of next login.

Upvotes: 2

Views: 2414

Answers (1)

MrTouch
MrTouch

Reputation: 654

Hi you have to use Basic User authentication.

I used this Tutorial for the use of Facebook JDK and Codeigniter in my Application: http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/

But I recommend you to use Javascript SDK for the authentication.

<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
  appId      : '[ID]', // App ID
  channelUrl : '[URL]', // Channel File
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  xfbml      : true  // parse XFBML
});  
var login = false;
 FB.getLoginStatus(function(response) {
          if (response.status === 'connected') {
              console.log('connected');
              login=true;
                // the user is logged in and connected to your
                // app, and response.authResponse supplies
                // the user's ID, a valid access token, a signed
                // request, and the time the access token 
                // and signed request each expire
                var uid = response.authResponse.userID;
                var accessToken = response.authResponse.accessToken;
          }
          else{
              FB.login(function(response) {
               if (response.authResponse) {
                 console.log('Welcome!  Fetching your information.... ');
                 FB.api('/me', function(response) {
                   console.log('Good to see you, ' + response.name + '.');
                   if(login===false)
                   {
                       window.open("[APPLINKONFACEBOOK]", "_top");
                   }
                   //window.location.href=window.location.href;
                   //FB.logout(function(response) {
                     //console.log('Logged out.');
                   //});
                 });
               } else {
                 console.log('User cancelled login or did not fully authorize.');
               }    
             }, {scope: 'email'});
          }});

// Additional initialization code here
};
 (function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol +
 '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);  
  }());
  // Load the SDK Asynchronously
 (function(d){
 var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 d.getElementsByTagName('head')[0].appendChild(js);
 }(document));

 </script>

Upvotes: 2

Related Questions