Important Bits

fix FB.getLoginStatus() called before calling FB.init()

September 19, 2012

To fix this error, I had to take a second look at my FB.init code.

I had just moved a site to a new server, and started seeing the error in Chrome’s dev console. I blamed Facebook for a few minutes and then spotted the problem after looking at my page’s source:

  appId      : '', // App ID
  channelUrl : '[an ok value]', // Channel File
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  xfbml      : true  // parse XFBML

appId was blank because the server-side code that defines it could not find appId in the environment variables or configuration after the move. When appId was corrected, everything worked again. Beware of the blank appId. It happened to this guy too.

Adam Sullovey

Written by Adam Sullovey, powered by Gatsby.
Find me on codepen, github, or at Toronto meetups.

tags: facebook, javascript