Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught ReferenceError: checkLoginState is not defined using facebook API

I keep trying to fix this code but I am stuck with this error on my console:

Uncaught ReferenceError: checkLoginState is not defined.

I simply followed this guide. Here is my code for this function and when I call it:

function checkLoginState() {
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
}


<fb:login-button data-max-rows="1" data-size="large" data-show-faces="false" data-auto-logout-link="true" onlogin="checkLoginState();" scope="public_profile, pages_show_list"></fb:login-button>
like image 389
MrToshio Avatar asked Feb 10 '16 15:02

MrToshio


1 Answers

This:

function checkLoginState() {
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
}

Should be inside your <script> block

<script>
    function checkLoginState() {
      FB.getLoginStatus(function(response) {
        statusChangeCallback(response);
      });
    }

    // Load the SDK asynchronously
    (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>
like image 87
Berriel Avatar answered Sep 28 '22 04:09

Berriel