Facebook FB.logout不';不要注销
我已经实现了基于Facebook的登录。 FB.login可以很好地工作,但是FB.logout不能。我尝试过使用不同的FB.init,删除cookies,连续多次运行注销页面,但唯一的注销方式是在facebook本身 我用于注销的代码是:Facebook FB.logout不';不要注销,facebook,login,logout,Facebook,Login,Logout,我已经实现了基于Facebook的登录。 FB.login可以很好地工作,但是FB.logout不能。我尝试过使用不同的FB.init,删除cookies,连续多次运行注销页面,但唯一的注销方式是在facebook本身 我用于注销的代码是: <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId: '***************',
xfbml: true,
status: true,
cookie: true
});
FB.getLoginStatus();
FB.logout();
</script>
FB.init({
appId:“****************”,
xfbml:是的,
状态:正确,
曲奇:是的
});
FB.getLoginStatus();
FB.logout();
有什么想法吗?
谢谢单击事件为FB.logout()时,您是否尝试过使用按钮
函数注销(){
FB.注销(功能(响应){
//用户现在已注销
});
}
注销
试试这个试试这个:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
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
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
window.fbAsyninit=函数(){
FB.init({
appId:'你的应用程序ID',//应用程序ID
channelUrl:'//WWW.YOUR_DOMAIN.COM/channel.html',//频道文件
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
//这里有额外的初始化代码
};
//异步加载SDK
(职能(d){
var js,id='facebook jssdk',ref=d.getElementsByTagName('script')[0];
if(d.getElementById(id)){return;}
js=d.createElement('script');js.id=id;js.async=true;
js.src=“//connect.facebook.net/en_US/all.js”;
ref.parentNode.insertBefore(js,ref);
}(文件);
然后调用FB.logout()。之前必须初始化FB
从文件中:
此代码异步加载SDK,因此不会阻止加载页面的其他元素。这对于确保用户和SEO机器人快速加载页面尤为重要
上面代码中的URL是协议相关的。这允许浏览器通过与包含页面相同的协议(HTTP或HTTPS)加载SDK,这将防止出现“不安全内容”警告
加载SDK后,将立即运行分配给window.fbasyninit的函数。加载SDK后要运行的任何代码都应放在该函数中,并放在调用FB.init之后。例如,您可以在这里测试用户的登录状态,或者订阅应用程序感兴趣的任何Facebook事件
您还需要在php中销毁会话,可以通过
session_destroy()完成代码>谢谢。你知道asp的等价物吗?尝试了session\u destroy()和session\u unset(),但仍然不起作用:(谢谢你的帮助。它确实起作用了!我确信我需要FB.init才能运行FB.logout。显然没有。
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
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
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>