Php Fb.Connect在执行Fb注销时未定义错误
我正在尝试为我的django应用程序实现facebook注销功能。Facebook登录对我来说很好。现在我需要注销并以某种方式清除会话。为此,我尝试使用下面的代码,但它抛出了“FB.Connect not defined”错误。有人能看看我的代码给我一个解决方案吗Php Fb.Connect在执行Fb注销时未定义错误,php,javascript,django,facebook,facebook-graph-api,Php,Javascript,Django,Facebook,Facebook Graph Api,我正在尝试为我的django应用程序实现facebook注销功能。Facebook登录对我来说很好。现在我需要注销并以某种方式清除会话。为此,我尝试使用下面的代码,但它抛出了“FB.Connect not defined”错误。有人能看看我的代码给我一个解决方案吗 <html xmlns:fb="http://www.facebook.com/2008/fbml"> <div id="fb-root"></div> <scri
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'xxx',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<script>
function logout(){
FB.logout(function(response) {
// user is now logged out
location.href = '/user_sessions/new';
});}
// handle a session response from any of the auth related calls
function handleFBSessionResponse(response) {
/*
//Check the facebook login status
alert("handleFBSessionResponse(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.session
+" \nresponse.perms="+response.perms);
*/
//if we do have a non-null response.session, call FB.logout(),
//the JS method will log the user out
//of Facebook and remove any authorization cookies
FB.logout(handleFBSessionResponse);
}
</script>
<a href="javascript:logout();">Logout</a >
FB.init({
appId:'xxx',
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
函数注销(){
FB.注销(功能(响应){
//用户现在已注销
location.href='/user_sessions/new';
});}
//处理来自任何与身份验证相关的调用的会话响应
函数handleFBSessionResponse(响应){
/*
//检查facebook登录状态
警报(“handleFBSessionResponse(),”
+“\nresponse.status=“+response.status”
+“\nresponse.session=“+response.session”
+“\nresponse.perms=“+response.perms”);
*/
//如果我们有一个非null response.session,则调用FB.logout(),
//JS方法将用户注销
//并删除任何授权cookie
FB.注销(handleFBSessionResponse);
}
注销
或者有没有其他简单直接的方法来实现它,如果有,请在这里发布代码
FB.logout(handleFBSessionResponse);
您在内部传递回调函数似乎很奇怪。尝试这样做:
FB.logout(function(response) {
// user is now logged out
location.href = '/user_sessions/new';
});
并删除代码中的另一个location.href引用。我已将其用于此操作
<a href="http://m.facebook.com/logout.php?confirm=1&next=http://10.1.0.90:8080/registrationForm" >Sign Out</a>
它给了我这个错误“FB.logout不是一个函数”;我应该删除“function handleFBSessionResponse(response)”方法吗?我已经更改了代码..现在控件没有进入Fb.connect.logout()中..调用的方法正确吗?