javascript - Facebook FB.getLoginStatus doesn't fire Callback -
i know there similar questions here on stackoverflow, there wasn't solution me in of them , i'm pretty desperate right now. i'm writing facebook app , works pretty neat far. fb.getloginstatus function doesn't fire callback users (a small percentage). able reproduce error on 1 machine , happened there , on chrome. user got problem chrome. found out, works if move facebook api code on own page (have no explanation this, commented out rest of code , did work sometimes, many times not). moved own page , send data got on getloginstatus function other page. did work pc, still got entries in database didn't work other users. have no idea why callback doesn't called, hope can me, in advance!
tldr: facebook api doesn't fire callback @ fb.getloginstatus function. happens on small percentage of machines , reproduce 2 machines (both on chrome, different user account, different os). code i'm using: https://jsfiddle.net/zfyb3zy4/
<script> window.fbasyncinit = function() { fb.init({ appid : '99999999999999999999', xfbml : true, version : 'v2.6' }); fb.getloginstatus(function(response) { if (response.status === 'connected') { localstorage.setitem("f_uid", response.authresponse.userid); fb.api(response.authresponse.userid+"?fields=id,name,email",function(response) { //window.location.href="game.html"; localstorage.setitem("name",response.name); localstorage.setitem("email",response.email); }); } else { fb.login(function (response) { if (response.authresponse == null) top.location.href="https://www.facebook.com/anexiagmbh"; localstorage.setitem("f_uid", response.authresponse.userid); fb.api(response.authresponse.userid+"?fields=id,name,email",function(response) { //window.location.href="game.html"; localstorage.setitem("name",response.name); localstorage.setitem("email",response.email); }); } ,{scope: 'email'}); } }, true); }; function onlogin(response) { if (response.status == 'connected') { fb.api('/me?fields=first_name', function(data) { var welcomeblock = document.getelementbyid('fb-welcome'); welcomeblock.innerhtml = 'hello, ' + data.first_name + '!'; }); } } (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/sdk.js"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>