对于我的生活,我无法获得Event.subscribe('auth.authResponseChange')的工作。请参阅下面的代码facebook FB.Event.subscribe('auth.authResponseChange')不起作用
<div id="fb-root">
</div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'XXXXXXXXXXXXXXX', // App ID
channelUrl: 'http://XXXXXXXX.us/', // Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
alert('The status of the session is: ' + response.status);
});
};
// 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>
<div class="fb-login-button" data-size="xlarge" scope="email" data-show-faces="false"
data-width="400" data-max-rows="1" autologoutlink="true">
Login with Facebook</div>
登录按钮呈现。我也可以注销。唯一的问题是,auth.response更改不会触发,我没有收到“消息”弹出框
FBML不久将被取消。最好不要使用它。 – InspiredJW 2012-07-27 10:03:49
@InspiredJW FBML已经被弃用,这是XFBML,不会被弃用的东西 – 2012-08-07 02:16:07
你有没有试过根据文档检查'response [0]'?*请注意,在某些情况下,响应的值是不加键的,但当返回多个变量时,它包含相应的键。* => http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/ – PlantTheIdea 2013-10-29 21:55:18