2012-03-16 4 views
2

페이스 북에서 페이스 북으로 로그인 할 때 페이스 북에서 정보에 액세스하는 방법. 로그인 성공 후 리디렉션하는 방법.codeigniter를 사용하여 페이스 북으로 로그인하는 방법

처음 로그인 할 때 다음 사용자의 정보를 가져올 때 다음 로그인의 프로세스 즉, 사용자가 처음 로그인 할 때 그 사용자의 정보가있는 경우 다음 로그인의 프로세스는 무엇입니까?

+1

이 모든 과정을 취소 한 facebook api 문서를 살펴보아야합니다. –

답변

2

안녕하세요. 기본 사용자 인증을 사용해야합니다.

나는 내 응용 프로그램에서 페이스 북 JDK 이그나이터의 사용이 튜토리얼을 사용 : http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/

하지만 난 당신이 인증을 위해 자바 스크립트 SDK를 사용하는 것이 좋습니다.

<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> 
관련 문제