目前,它具有FB登录按钮的最基本实现,该按钮在身份验证后自动变为注销按钮。现在我希望用户登录后背景会改变颜色,并在用户注销后恢复。
登录后,是否可以将Facebook图片的位置和大小远离登录按钮?
提前致谢。
答案 0 :(得分:1)
您可以通过JS SDK的auth.statusChange
功能捕获FB.Event.subscribe
事件。有关说明,请参阅https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/#login-logout。此外,您可以查看https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus
例如
var loginCallback= 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
document.body.style.background = "red";
} 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.
document.body.style.background = "green";
}
}
// In your onload handler add this call
FB.Event.subscribe('auth.statusChange', loginCallback);