由于 Facebook昨天更新了其开发人员路线图更改,因此我的网站存在重大问题,因为它具有 Facebook 登录依赖项。
我相信问题出在下面提供的我的 Facebook JS SDK:
<script type="text/javascript">
(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 = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
var button;
var userInfo;
window.fbAsyncInit = function() {
FB.init({
appId: 'ID', //change the appId to your appId
channelUrl : '//www.DOMAIN.com/channel.html', // Channel File
status: true,
cookie: true,
xfbml: true,
oauth: true});
showLoader(false);
function updateButton(response) {
button = document.getElementById('fb-auth');
userInfo = document.getElementById('user-info');
if (response.authResponse) {
//user is already logged in and connected
FB.api('/me', function(info) {
login(response, info);
});
button.onclick = function() {
FB.logout(function(response) {
logout(response);
});
$.post('scripts/logout.php',{ facebook_id:response.authResponse.userID } , function(data) {
//kill sessions
});
};
} else {
//user is not connected to your app or logged out
button.innerHTML = '';
button.onclick = function() {
showLoader(false);
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(info) {
login(response, info);
});
} else {
//user cancelled login or did not grant authorization
showLoader(false);
}
window.location.href='/user/index.php';
}, {scope:'email,user_birthday,status_update,publish_stream,user_about_me'});
}
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
window.top.location = '../user/index.php';
}
});
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
//FB.Event.subscribe('auth.statusChange', updateButton);
// FB login insert/update
// Additional init code here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
FB.api('/me', function(info) {
getLoginStatus(response, info);
});
if (response.authResponse.userID) {
$.post('scripts_profile/init.php',{ facebook_id:response.authResponse.userID } , function(data) {
//Good
});
} else {
//Nothing
}
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
};
// 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>
我的网站还有与 Facebook JS SDK 集成的 Facebook PHP SDK。
由于 Facebook 更新,JS SDK 没有像以前那样与 PHP 集成,导致不一致。
例如,在我的网站上,如果用户登录,他们的标题与访问者不同。所以根据 FB PHP SDK:
if (!my_profile) {
//user header
} else {
//visitor header
}
由于更新,一旦登录,登录用户需要刷新页面以查看它应该......而不是简单地访问它。一旦我尝试直接访问该页面(通过单击链接或输入网址),它就会显示我已注销!
我花了最后 10 个小时来解决它,我真的迷路了。您的帮助将不胜感激!
谢谢大家。