글쎄, 사용자가 로그인하거나 로그 아웃 한 시점을 감지하기 위해 Facebook의 Javascript API를 사용해야하고 헤더를 업데이트하기위한 AJAX 요청을해야합니다. 다음 코드가 지적 하듯이이 FB.Event.subscribe를 통해 수행 할 것입니다 :
window.fbAsyncInit = function() {
FB.init({
appId : 'YOURAPPID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://www.yourdomain.com/channel.html', // Custom Channel URL
oauth : true //enables OAuth 2.0
});
// retrieve the login status.
FB.getLoginStatus(function(response) {
if (response.authResponse) update_user_is_connected();
else update_user_is_not_connected();
});
// This will be triggered as soon as the user logs into Facebook (through your site)
FB.Event.subscribe('auth.login', function(response) {
// Here you would update your header.
update_user_is_connected();
});
};
현재 FB.Event.subscribe에 대한 자세한 내용을보실 수 있습니다 : http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
이 코드는 previous에서 가져옵니다 유의하시기 바랍니다 내 answers.
나는 이미 모든 작업을 수행하고 있으며, 사람을 로그 아웃하기 위해 AJAX 호출을 보내고 있습니다. 웬일인지 일반 사이트는 그 사실을 반영하지 않습니다. – Genadinik
내가 게시 한 링크를 보면 fb에서 로그인하거나 로그 아웃 했더라도 사이트의 일반 사용자 세션을 업데이트하기 위해 작성한 ajax 호출은 오른쪽 상단에 로그인/로그 아웃 링크를 반영하지 않습니다. – Genadinik
예, 이것은 사용자가 로그인했는지 여부를 (PHP에서) 확인하지 않았기 때문에 분명합니다. 이 작업은 getUser()를 통해 수행 할 수 있습니다. –