我正在使用 Facebooks 文档中的登录代码:
这在桌面浏览器中运行良好,但在平板电脑上,整个站点会尝试重定向到https://m.facebook.com...
URL,而不是显示权限弹出。它重定向到的页面只显示错误。弹出窗口不能在 Facebook Javascript SDK 中工作吗?
<div id="fb-root"></div>
<script type="text/javascript">
var likesPage = false;
var addisPageId = 'XXXXXX';
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: 'XXXXXXX', // App ID from the app dashboard
channelUrl: '/channel.html', // Channel file for x-domain comms
status: true, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(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_gb/all.js";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
function callLogin() {
FB.login(function (response) {
var access_token = FB.getAuthResponse()['accessToken'];
$("#at").val(access_token);
if (response.authResponse) {
FB.api('/me/likes?fields=id', function (response) {
for (var i = 0; i < response.data.length; i++) {
if (response.data[i].id == addisPageId) {
likesPage = true;
break;
}
}
if (likesPage) {
FB.api('/me', function (userInfo) {
document.getElementById("email").value = userInfo.email;
document.getElementById("fbId").value = userInfo.id;
document.getElementById("fbform").submit();
});
} else {
document.getElementById("dontLikePage").style.display = "inline";
}
});
} else {
window.parent.location = "https://www.facebook.com/XXXX";
}
}, { scope: 'user_likes,email,publish_stream' });
}
</script>