我正在尝试在我的网页中包含 facebook 登录/注册插件。每当我单击登录或单击注销时,应触发相应的FB.Event.subscribe。但就我而言,登录和注销成功发生。但这些事件都没有被触发。在代码下方找到,
<div id="fb-root"></div>
window.fbAsyncInit = function(){
FB.init({
appId : 'xxxxxxxxxxxxxxxxxxxx',
status : true,
cookie : true,
oauth : true,
xfbml : true
});
FB.Event.subscribe('auth.login', function(response) {
FB.api('/me', function(response) {
alert('You have successfully logged in, '+response.name+"!");
});
});
FB.Event.subscribe('auth.logout', function(response) {
FB.api('/me', function(response) {
alert('You have successfully logged out, '+response.name+"!");
});
});
FB.getLoginStatus(function(response) {
if (response.session) {
alert('Hello');
}
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
如果有人能在这里帮助我,那就太好了。提前致谢。