2

我正在寻找官方的“使用 Facebook 登录”按钮,但在他们的网站上找不到。例如 Spotify 使用它

https://www.spotify.com/de/ -> “Anmelden” -> “Mit Facebook anmelden”

我在这里找到了这个:

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

但它不是我要找的那个。老实说,那个很蹩脚。

有谁知道我在哪里可以找到它 - 或者 Spotify 例如使用的那个甚至不是官方的?

谢谢你的帮助。

4

3 回答 3

2

构建您自己的 Facebook-Login-Button 并使用以下代码实现登录功能:

<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>
于 2013-08-21T13:06:33.030 回答
0

如果我做对了,您需要使用 facebook 登录进行 facebook 身份验证

请参考此链接developer.facebook.com

在这里,你会得到你想要的一切,

1) 在这里您将找到多种选项来实现您的要求

注意:现在不推荐使用 Iframe 选项,因此必须使用JavaScriptSDK

这是创建登录按钮的链接

你准备好了..

上面的链接中提供了示例代码(下面提供了示例)..

第 1 步:在正文标记开头编写脚本代码。

    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = 'https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v3.2';
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

第 2 步:将此代码放置在您希望此插件出现的位置

<div class="fb-login-button" data-max-rows="1" data-size="large" data-button-type="continue_with" data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="false">
</div>

注意:用户可以在一定程度上自定义 UI 参考上面链接中的“Plugin Configurator”。

我相信任何技术人员都可以使用它来实现!

于 2013-08-21T13:06:47.233 回答
-2

facebook 标志和按钮的官方位置是:

https://www.facebookbrand.com/

于 2014-02-09T23:36:45.157 回答