1
你好我嘗試當用戶點擊與Facebook按鈕登錄設置POST。這是因爲我做了,如果您已註銷,但在Facebook的loged代碼那麼你會自動在該網站再次loged ......所以如果你CLIC註銷,你永遠不會登出..添加POST參數FB:登錄按鈕
爲了避免這種情況我嘗試把一根柱子,設置一個經典的條件
if (isset ($_POST['fbconnect']))
我只需要添加一個隱藏的輸入,併發送形式usinf fb:登錄按鈕
這裏是我有什麼嘗試......沒有運氣。
<form name="fbconnect" method="post">
<input type="hidden" name="fbconnect" value="fbconnect" />
<div id="fb-root"></div>
<fb:login-button scope='email,user_birthday'></fb:login-button></form>
<?php
}
?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?=YOUR_APP_ID?>,
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function(response) {
// ------------------------------------------------------
// This is the callback if everything is ok
$(this).parents('form').submit();
});
};
(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>
而且香港專業教育學院試圖與形式的名稱,以取代$(this).parents('form').submit();
形式,但它dosent工作要麼
我也試過這個
<script>
window.fbAsyncInit = function() {
FB.init({
appId : <?=YOUR_APP_ID?>,
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function(response) {
// ------------------------------------------------------
// This is the callback if everything is ok
var url = "index.php";
var params = "fbconnect=fbconnect";
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
});
};
(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>
對不起,也許你的答案其巨大的,但我真的在JavaScript中的小白,這就是爲什麼我最終嘗試PHP解決方案,也是我在一個代碼中實現這一點,我不能觸摸註銷設置,並基於Cookie,我只是根據Cookie做出條件,看看它是否登錄或不。 ..我會嘗試,如果你告訴我如何使用該腳本,或者真的像複製粘貼那麼簡單?,非常感謝(我很害怕與當前註銷混亂,我不能混淆當前註銷) –
隨着第二個解決方案,我得到了這個阻止與來源「https://www.facebook.com」框架來源訪問框架「http://ct1.addthis .COM」。請求訪問的幀具有「https」的協議,被訪問的幀具有「http」的協議。協議必須匹配。 –
你的第一個建議是工作,但PLS!回答這個我只需要條件狀態與我的網站,以及Facebook的狀態,response.status!=「連接」...但我是一個傻瓜在Javascript ..如果我不條件這會產生一個循環 –