开发者

FB.getLoginStatus doesn't work?

The FB.getLoginStatus function doesn't work for me for some reason - although it used to for some time. Very basic code below, and the alert never popups - looks like FB.getLoginStatus never calls the supplied function. Any ideas ?

<body>
<form id="form1" runat="server">
<div id="fb-root">
</div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
    FB.init({ appId: 'xxx', status: true, cookie: true, xfbml: true });
    FB.getLoginStatus(function (response) {
        alert("Hi there");
    });
</script>
</form>
开发者_JS百科


If your app is in Sandbox Mode see this bug: https://developers.facebook.com/bugs/240058389381072

Also read the comments by Philip Bulley

[...] Essentially sandboxed applications are invisible to non-app-developers. If there is no user currently logged into Facebook, Facebook will act as if your sandboxed application doesn't exist at all (FB obviously doesn't know you're an app developer, and thus the app is invisible!).

This bug has been confirmed and assigned.


In which platform you are developing the application??If it is FBML then check FBJS-Facebook JavaScript.I think alert will not work in FBML application. I got this working..Just check

<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
    FB.init({appId: 'APP_ID', status: true, cookie: true, xfbml: false});
};
(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);
}());
window.fbAsyncInit = function() {
     FB.init({appId: 'APP_ID', status: true, cookie: true, xfbml: true});

         /* All the events registered */
         FB.Event.subscribe('auth.login', function(response) {
             // do something with response
             login();
         });
         FB.Event.subscribe('auth.logout', function(response) {
             // do something with response
             logout();
         });

         FB.getLoginStatus(function(response) {
             if (response.session) {
                 // logged in and connected user, someone you know
                 login();
             }
         });
     };

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜