Facebook登录按钮将不会出现并且无法使用

时间:2019-03-12 08:50:37

标签: javascript html facebook-javascript-sdk

我试图添加一个简单的登录按钮,该按钮提供了很多错误,但我什至看不到该按钮(猜测我的代码中缺少一些基本的东西)

我的 html

           <fb:login-button scope="public_profile,email" onlogin="checkLoginState();"><br></fb:login-button><br><div id="status"><br></div>

JS

function statusChangeCallback(response) {

    // The response object is returned with a status field that lets the app    know        the current login status of the person.
  if (response.status === 'connected') {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.name + '!';
    });
  } else if (response.status === 'not_authorized') {
    // The person is logged into Facebook, but not your app.
    document.getElementById('status').innerHTML = 'Please log ' + 'into this app.';
  } else {
    // The person is not logged into Facebook, so we're not sure if they are logged into this app or not.
    document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.';
  }

}


// This function is called when someone finishes with the Login Button.
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 = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";

    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));




window.fbAsyncInit = function() {
  FB.init({
    appId : 'XXXXXXXXXXXXXXXX',
    cookie : true, // enable cookies to allow the server to access the session
    xfbml : true, // parse social plugins on this page
    version : 'v2.1' // use version 2.1
  });

  // Now that we've initialized the JavaScript SDK, we call FB.getLoginStatus().
  // This function gets the state of the person visiting this page.
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
};

我遇到很多错误,但看不到按钮(在Mac本地运行并在chrome inspector中打开)。

The method FB.getLoginStatus will soon stop working when called from http pages. Please update your site to use https for Facebook Login.

The Login Button plugin will soon stop working on http pages. Please update your site to use https for Facebook Login.



Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.

0 个答案:

没有答案