您好,当用户单击使用 facebook 按钮登录时,我试图设置一个 POST。这是因为在我制作的代码中,如果您已注销,但在 facebook 中登录,那么您将自动再次登录该站点...因此,如果您单击注销,则永远不会注销..
为了避免这种情况,我试图设置一个 POST ,设置一个经典条件
if ( isset ($_POST['fbconnect']))
我只需要添加一个隐藏的输入并将该表单发送到 usinf fb:login-button
这是我尝试过的......没有运气。
<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();
表单名称替换表单,但它也不起作用
我也试过这个
<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>