title: FB.login() called before calling FB.init()
body: <p>I have seen this question in SO several times. Most of cases user called facebook js (all.js) twice or did not provide the application id. But my case is different. I have included all.js once and I also have set application id. But still I am getting this error "FB.login() called before calling FB.init()" when I click the login button. The markup for login button is as follows </p>
  
  <pre><code>&lt;fb:login-button autologoutlink="true" perms="email,user_birthday,user_about_me,publish_stream"&gt;&lt;/fb:login-button&gt;
  </code></pre>
  
  <p>And the javascript codes are</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          FB.init({appId: '${section.parameters['facebook.app.id']}', status: true, cookie: true, xfbml: true});
  
          /* All the events registered */
          FB.Event.subscribe('auth.login', function(response) {
            window.location.reload();
          });
          FB.Event.subscribe('auth.logout', function(response) {
            // do something with response
            //logout();
          });
  
        function setFacebookStatus(form) {
              var status = $('#comment-form-body').val();
              var params = {};
              params['message']= status;
              params['link'] = '${article.url}';
              FB.api('/me/feed', 'post',params, function(response) {
                if (!response || response.error) {
                  alert('Error occured');
                }
                else {
                  alert('&lt;fmt:message key="comment.form.facebook.success" /&gt;');
                  $("#facebookComment").overlay().close();
                  form.submit();
                }
              });
        }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>I have added all.js in the header of my html page. I am really pissed off this issue. I would be very grateful if you help me.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>One more thing to mention. Sometimes it works and sometimes it shows me the warning. Say I was logged in to facebook from another tab and then I logged out from facebook. Then I refresh my website page that has the facebook integration. Then I get the warning. Main problem is that sometimes it is working sometimes not.</p>