Facebook not responding to Javascript API calls -


i attempting use facebook's javascript sdk user's login status when page displayed.

the code using follows:

fb.getloginstatus(function(response) {     if (response.status == 'connected') {       alert('logged in');     } else {        alert('need log in!');     }   }); 

i go through facebook initialization without problems, , fb.getloginstatus() function gets called, apparently facebook server not respond. not receive response of kind.

i did put application's id initialization function, , initialization code downloaded facebook. debugging on firefox using firebug, know initialization successful , fb.getloginstatus() call being made. not getting response server.

can suggest reasons why not getting response? if so, please advise.

addition:

in response sahil mittal's request, entire code provided below. should noted there isn't more see...

<script type="text/javascript"> window.fbasyncinit = function() { fb.init({   appid      : xxxxxxxxxxxx,   status     : true,   xfbml      : true }); };  (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/all.js";  fjs.parentnode.insertbefore(js, fjs);  }(document, 'script', 'facebook-jssdk'));   fb.getloginstatus(function(response) {     if (response.status == 'connected') {       alert('logged in');     } else {        alert('need log in');     }   }); </script> <body> <div id="fb-root"></div>   ... </body> 

credit answer should go cbroe. wish cbroe had put answer give proper credit.

nevertheless, answer question place fb functions inside window.fbasyncinit() function, in following example:

  window.fbasyncinit = function() { fb.init({   appid      : xxxxxxxxxxxxx,   status     : false,   xfbml      : true });  fb.getloginstatus(function(response) {     if (response.status == 'connected') {       alert('logged in');     } else {        alert('need log in');     }   }); }; 

this not documented on facebook (what else new???), posting other facebook newbies can avoid frustration , delay experienced.

again: should go cbroe answer.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -