sab*_*our 25 facebook facebook-graph-api
我正在尝试在我的网站上使用新的Facebook Graph API.这就是我所拥有的:
在页面的某个地方:
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
Run Code Online (Sandbox Code Playgroud)
标签后面:
<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>
Run Code Online (Sandbox Code Playgroud)
但是当我点击生成的登录按钮时,没有任何反应.
另外,我得到了
FB.getLoginStatus() called before calling FB.init().
Run Code Online (Sandbox Code Playgroud)
在Firebug控制台中.
有任何想法吗?
sab*_*our 44
我无法相信,我在Web.config中引用了一个不存在的键,因此FB.init默默地失败了.
它现在按预期工作.
为了更清楚,我没有将appId传递给FB.init,一旦我这样做,它就有效了.
| 归档时间: |
|
| 查看次数: |
45494 次 |
| 最近记录: |