我正在尝试使用 Open Graph API 实现“使用 Facebook 登录”。到目前为止,这适用于 FF、Chrome、Safari,但不适用于 IE。在 IE9 上测试。
在 IE 上,我得到用于登录的 Facebook 对话框。我可以成功登录 Facebook,但没有任何反应。在其他浏览器上,页面重定向并将 fb 用户数据存储到数据库中。
我也在不同的场合尝试了这两种 FB 文档类型,但没有成功。
xmlns:fb="http://ogp.me/ns/fb#"
xmlns:fb="http://www.facebook.com/2008/fbml"
编辑:我删除了 FB.api 内容只是为了包含一个用于测试的警告框。适用于除 IE 之外的所有内容。
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $AppID; ?>',
channelUrl : '//www.mysite.net/channel.php', // Channel File
oauth : true,
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
function fb_login(){
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
//console.log(response); // dump complete info
access_token = response.authResponse.accessToken; //get access token
user_id = response.authResponse.userID; //get FB UID
FB.api('/me', function(response) {
alert(response.id);
});
} else {
//user hit cancel button
console.log('User cancelled login or did not fully authorize.');
}
}, {
scope: 'email,publish_actions'
}
);
}
// 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>
最佳答案
尝试删除/注释掉代码的 console.log() 区域,我知道这很疯狂,但上次我在 IE 中尝试这些时,他们提示无法调用未定义的日志...我希望 IE 能够捕捉到与时俱进。
如果有的话,请试一试,它绝对值得一试,因为它可能很简单。请相信我知道这听起来很傻,但它一直是我过去 IE 错误的来源!
关于php - Facebook API,使用 Facebook 登录不能仅在 IE 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10476587/