Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Asp.net注销Facebook?_Asp.net_.net_Facebook_Facebook C# Sdk - Fatal编程技术网

如何从Asp.net注销Facebook?

如何从Asp.net注销Facebook?,asp.net,.net,facebook,facebook-c#-sdk,Asp.net,.net,Facebook,Facebook C# Sdk,我正在使用下面的代码使用我的Asp.net应用程序登录Facebook 我可以完全登录…但我如何才能从FB注销 <input type="button" id="fblogin" value="Login to Facebook" disabled="disabled" style="display: none" /> <fb:login-button v="2" autologoutlink='true' length="long" onlogin="$('#fblogin'

我正在使用下面的代码使用我的Asp.net应用程序登录Facebook

我可以完全登录…但我如何才能从FB注销

<input type="button" id="fblogin" value="Login to Facebook" disabled="disabled" style="display: none" />
<fb:login-button v="2" autologoutlink='true' length="long" onlogin="$('#fblogin').click()">Login to Facebook</fb:login-button>  

<script>
    window.fbAsyncInit = function () 
    {
        FB.init({
            appId: '<%: Facebook.FacebookApplication.Current.AppId %>',
            cookie: true,
            xfbml: true,
            oauth: true
        });

        function facebooklogin() {
            FB.login(function (response) {
                if (response.authResponse) {
                    // user authorized
                    // make sure to set the top.location instead of using window.location.reload()
                    top.location = '<%= this.ResolveCanvasPageUrl("~/") %>';
                } else {
                    // user cancelled
                }
            }, { scope: '<%: string.Join(",", ExtendedPermissions) %>' });
        };

        $(function () {
            // make the button is only enabled after the facebook js sdk has been loaded.
            $('#fblogin').attr('disabled', false).click(facebooklogin); });
        });

    };
    (function () {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    } ());
</script>

登录Facebook
window.fbAsyninit=函数()
{
FB.init({
appId:“”,
曲奇:是的,
xfbml:是的,
真的吗
});
函数facebooklogin(){
FB.登录(功能(响应){
if(response.authResponse){
//用户授权
//确保设置top.location,而不是使用window.location.reload()
top.location='';
}否则{
//用户取消
}
},{作用域:'});
};
$(函数(){
//make按钮仅在facebook js sdk加载后启用。
$('#fblogin').attr('disabled',false)。单击(facebook登录);});
});
};
(功能(){
var e=document.createElement('script');e.async=true;
e、 src=document.location.protocol+'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
} ());
使用此代码

<div id="user-info"></div>
<p><button id="fb-auth">Login using facebook</button></p>



<script type="text/javascript">
    window.fbAsyncInit = function () {
        FB.init({ appId: 'appid',
            status: true,
            cookie: true,
            xfbml: true,
            oauth: true
        });

        function updateButton(response) {
            var button = document.getElementById('fb-auth');

            if (response.authResponse) {
                //user is already logged in and connected
                var userInfo = document.getElementById('user-info');
                FB.api('/me', function (response) {
                    userInfo.innerHTML = '<img src="https://graph.facebook.com/'
      + response.id + '/picture">' + response.name + response.email;
                    button.innerHTML = 'Logout';



                });
                button.onclick = function () {
                    FB.logout(function (response) {
                        var userInfo = document.getElementById('user-info');
                        userInfo.innerHTML = "";
                        //to textbox
                        document.getElementById('TxtFname').value = "";
                        document.getElementById('Txtemail').value = "";
                    });
                };
            } else {
                //user is not connected to your app or logged out
                button.innerHTML = 'Login using facebook';
                button.onclick = function () {
                    FB.login(function (response) {
                        if (response.authResponse) {
                            FB.api('/me', function (response) {
                                var userInfo = document.getElementById('user-info');
                                userInfo.innerHTML =
                '<img src="https://graph.facebook.com/'
            + response.id + '/picture" style="margin-right:5px"/>'
            + response.name + "emailid" + response.email;
                            });
                        } else {
                            //user cancelled login or did not grant authorization
                        }
                    }, { scope: 'email' });
                }
            }
        }

        // run once with current status and whenever the status changes
        FB.getLoginStatus(updateButton);
        FB.Event.subscribe('auth.statusChange', updateButton);
    };

    (function () {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol
    + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    } ());

</script>   

使用facebook登录

window.fbAsyninit=函数(){ FB.init({appId:'appId', 状态:正确, 曲奇:是的, xfbml:是的, 真的吗 }); 函数更新按钮(响应){ var button=document.getElementById('fb-auth'); if(response.authResponse){ //用户已登录并连接 var userInfo=document.getElementById('user-info'); FB.api('/me',函数(响应){ userInfo.innerHTML=''+response.name+response.email; button.innerHTML='Logout'; }); button.onclick=函数(){ FB.注销(功能(响应){ var userInfo=document.getElementById('user-info'); userInfo.innerHTML=“”; //到文本框 document.getElementById('TxtFname')。value=“”; document.getElementById('Txtemail')。value=“”; }); }; }否则{ //用户未连接到您的应用或未注销 button.innerHTML='使用facebook登录'; button.onclick=函数(){ FB.登录(功能(响应){ if(response.authResponse){ FB.api('/me',函数(响应){ var userInfo=document.getElementById('user-info'); userInfo.innerHTML= '' +response.name+“emailid”+response.email; }); }否则{ //用户已取消登录或未授予授权 } },{范围:'电子邮件'}); } } } //使用当前状态运行一次,并在状态更改时运行一次 FB.getLoginStatus(更新按钮); FB.Event.subscribe('auth.statusChange',updateButton); }; (功能(){ var e=document.createElement('script');e.async=true; e、 src=document.location.protocol +“//connect.facebook.net/en_US/all.js”; document.getElementById('fb-root').appendChild(e); } ());
这很有效

?? 下一步=您的\u重定向\u URL
&access\u token=USER\u access\u token

出于某些原因,我需要修改用于登录的脚本。所以我不能直接使用你的代码。你能帮我在我的代码中添加注销功能吗?请检查这个URL,看看它对你有什么帮助,或者检查facebook开发者