2012-06-22 35 views
0

我正在使用Facebook C#SDK來允許用戶使用Facebook登錄我的網站。從我的網站註銷Facebook#c#sdk - 但完全沒有離開Facebook?

要註銷,我可以使用fb.logout,但這會將用戶從Facebook以及我的網站中記錄下來,這似乎對用戶來說非常煩人和不必要。

我非常有信心當他們註銷我的網站時,他們不必退出Facebook,因爲digg.com完全提供了我之後的功能 - 登錄和退出Facebook,無需日誌記錄用戶離開他們的Facebook帳戶。

下面是我在使用日誌的代碼輸入/輸出:

<div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function() { 
      FB.init({ 
       appId: 'XXXXXXXXXXXX', // App ID 
       status: true, // check login status 
       cookie: true, // enable cookies to allow the server to access the session 
       xfbml: true // parse XFBML 
      }); 

      // Handle successful log in. 
      FB.Event.subscribe('auth.authResponseChange', function (response) { 
       if (response.status === 'connected') { 
        // the user is logged in and has authenticated your 
        // app, and response.authResponse supplies 
        // the user's ID, a valid access token, a signed 
        // request, and the time the access token 
        // and signed request each expire 
        var uid = response.authResponse.userID; 
        var accessToken = response.authResponse.accessToken; 

        // Handle the access token 
        // Do a post to the server to finish the logon 
        // This is a form post since we don't want to use AJAX 
        var form = document.createElement("form"); 
        form.setAttribute("method", 'post'); 
        form.setAttribute("action", '/login.aspx'); 

        var field = document.createElement("input"); 
        field.setAttribute("type", "hidden"); 
        field.setAttribute("name", 'accessToken'); 
        field.setAttribute("value", accessToken); 
        form.appendChild(field); 

        document.body.appendChild(form); 
        form.submit(); 

       } else if (response.status === 'not_authorized') { 
        // the user is logged in to Facebook, 
        // but has not authenticated your app 
        alert("Logged in to facebook but not authenticated MT"); 
       } else { 
        // the user isn't logged in to Facebook. 
       } 
      }); 
     }; 

     // 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> 

    <div class="fb-login-button" autologoutlink="true"></div> 

你會看到,當用戶登錄時,我重定向到/login.aspx,它提供了我的網站的登錄功能(使用.net身份驗證),並將accesstoken保存到會話以供用戶會話期間使用。

我需要註銷按鈕來做同樣的事情,但相反,沒有完全將用戶從Facebook中註銷。

我已經在網上查找了幾個小時,但似乎無法找到調用fb.logout的任何方式,而無需將用戶從他們的Facebook帳戶中註銷。如果digg.com可以做到這一點,我一定也能夠做到,當然?

非常感謝,

保羅

回答

0

我很有信心,他們不必註銷的Facebook時,他們登出我的網站

Facebook Platform Policies別的說法 - 部分I.特徵和功能,#6

您的網站必須提供明確的「註銷」選項,該選項也會將用戶從Facebook註銷。

+0

啊,好的。我想digg.com不介意違反政策。那麼這使得這非常簡單 - 那麼非常感謝您的幫助。 Paul – PMcG