我正在寻找官方的“用Facebook登录”按钮,但我在他们的网站上找不到它。 例如。 Spotify使用它
https://www.spotify.com/de/ - > “登陆” - > “Mit Facebook anmelden”
我在这里找到了这个:
https://developers.facebook.com/docs/reference/plugins/login/
但它不是我要找的那个。 说实话,这是非常蹩脚的。
有没有人知道我在哪里可以找到它 - 或者是Spotify例如使用甚至不官方?
感谢您的帮助。
答案 0 :(得分: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>
答案 1 :(得分:0)
如果我说得对,你需要使用facebook登录进行facebook身份验证
请参阅此链接developer.facebook.com
在这里,您将得到您想要的一切,
1)在这里,您将找到满足您需求的多种选择
注意:现在不推荐使用Iframe选项,因此必须使用JavaScriptSDK
以下是创建Login Button
的链接你准备好了......
示例代码可在上面的链接中找到(下面提供的示例)..
步骤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请参阅上面链接中的“插件配置器”。
我相信任何技术人员都可以使用它!
答案 2 :(得分:-2)
facebook徽标和按钮的官方位置是: