-1
我使用Facebook的JavaScript的SDK的登錄按鈕,在我的網站能正常工作,但我缺少兩個用例Facebook登錄循環周圍
- 每當Facebook的cookie是可用時,它是從index.php來重定向event.php頁面,即使我正在觸發FB.login()函數的點擊事件。
- 當用戶點擊退出按鈕在我的網站我正在index.php文件重定向它,加載index.php頁面後,它再次被重定向到event.php頁
這裏是我的代碼中的index.php
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '375834632488230', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
FB.Event.subscribe('auth.login', function(response) {
window.location="http://mysite.com/event.php";
});
function doLogin(){
console.log("clicked on fb");
FB.login(function(response) {
if (response.session) {
FB.api('/me?fields=email,location,name,first_name,last_name,picture',
function (response) { });
}
} , {scope:'email'});
}
</script>
<a href="#" id="fblogin" class="signinfacebook" onclick="doLogin()">Sign in with
Facebook</a>