2013-08-21 24 views
2

我正在尋找官方的「使用Facebook登錄」按鈕,但我無法在他們的網站上找到它。 例如Spotify的使用它我在哪裏可以找到官方的「使用Facebook登錄」按鈕?

https://www.spotify.com/de/ - > 「登陸」 - > 「麻省理工學院的Facebook登陸」

我發現這一個位置:

https://developers.facebook.com/docs/reference/plugins/login/

,但它不是一個我在尋找。 說實話,這是一個很蹩腳的事情。

有沒有人有一個想法,我可以找到它 - 或者是一個Spotify例如甚至不使用官方?

感謝您的任何幫助。

回答

2

構建自己的Facebook - 登錄按鈕,使用下面的代碼登錄功能:

<div class="fb-login-button" data-scope="email" onclick="fbStatus();">Connect</div> 

<script> 
    function fbInit() { 
     window.fbAsyncInit = function() { 
      FB.init({ 
       appId: 'XXXXX', 
       status: false, 
       cookie: true, 
       xfbml: true 
      }); 

      //auth.statusChange 
      FB.Event.subscribe('auth.authResponseChange', function (response) { 
       if (response.status.indexOf('connected') != -1) { 
        // 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 

        }); 

       } else if (response.status.indexOf('not_authorized') != -1) { 
        // the user is logged in to Facebook, 
        // but has not authenticated your app 
       } else { 
        // the user isn't logged in to Facebook. 
       } 
      }); 
     }; 
    (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)); 
} 

function fbStatus() { 

    //auth.statusChange 
    FB.Event.subscribe('auth.authResponseChange', function (response) { 
     if (response.status.indexOf('connected') != -1) { 
      // 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 

      }); 

     } else if (response.status.indexOf('not_authorized') != -1) { 
      // the user is logged in to Facebook, 
      // but has not authenticated your app 
     } else { 
      // the user isn't logged in to Facebook. 
     } 
    }); 

    FB.getLoginStatus(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 

      }); 
     } else if (response.status === 'not_authorized') { 
      // the user is logged in to Facebook, 
      // but has not authenticated your app 
     } else { 
      // the user isn't logged in to Facebook. 
     } 
    }); 
} 
</script> 
-1

如果我得到它的權利,你需要Facebook的身份驗證與Facebook登錄

請參考以下鏈接developer.facebook.com

在這裏,你會得到你想要的一切,

1)在這裏,你會發現多種選擇ACHI前夜你需要

之後,你決定你想要什麼,

下面是創建Login Button

的鏈接,你準備好去..

示例代碼可在上面的鏈接..

我相信將能夠使用以實現..

+0

我已經創建了一個應用程序,並實施了標準按鈕,但我認爲有一些方法來定製它 - 我已經看到了我的例子很多那個按鈕,認爲有可能成爲它的官方版本,但我可能是錯的。 – DonMB

+0

請提供您的代碼更詳細的解決方案,小提琴將盡最大努力.. :)如果其按鈕的大小具體然後請更具體的要求。 – MarmiK

+0

我通過https://developers.facebook.com/docs/reference/plugins/login/創建它 那不是問題。問題是按鈕的佈局。它看起來不是我希望它看起來如何。但我想這是官方的,並且沒有可能改變它。 – DonMB

相關問題