我正在尝试在我的网站上使用新的 Facebook Graph API。这就是我所拥有的:
页面上的某处:
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
就在标签之后:
<div id="fb-root">
</div>
<script type="text/javascript">
window.fbAsyncInit = function () {
FB.init({ appId: '<%= ConfigurationManager.AppSettings["FBAppId"] %>', status: true, cookie: true, xfbml: true });
/* All the events registered */
FB.Event.subscribe('auth.login', function (response) {
// do something with response
alert("login success");
});
FB.Event.subscribe('auth.logout', function (response) {
// do something with response
alert("logout success");
});
FB.getLoginStatus(function (response) {
if (response.session) {
// logged in and connected user, someone you know
alert("login success");
}
});
};
(function () {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
} ());
</script>
但是当我单击生成的登录按钮时,什么也没有发生。
另外,我得到
FB.getLoginStatus() called before calling FB.init().
在 Firebug 控制台中。
有任何想法吗?
我不敢相信,我引用了 Web.config 中不存在的密钥,因此 FB.init 默默地失败了。
现在它按预期工作了。
为了更清楚我没有将 appId 传递给 FB.init,一旦传递,它就起作用了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)