简体   繁体   中英

facebook login dialog box in my site

The login dialog box coming without clicking the login button.

How to stop loading dialog box without clicking 'login'

check my site http://wwwtechnologies.com/ I have given this settings in fb apps App Domain:wwwtechnologies.com Website with Facebook Login:http://wwwtechnologies.com/

Another question:

How to get the facebook name of that person

<!-- FB LOGIN -->

<div id="fb-root"></div>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId      : 'xxxxxxxx', // App ID
//channelUrl : '//wwwtechnologies.com/channel.html', // Channel File
status     : true, // check login status
cookie     : true, // enable cookies to allow the server to access the session
xfbml      : true  // parse XFBML
});

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
// Additional init code here

};

// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));

function login() {
FB.login(function(response) {
if (response.authResponse) {
testAPI();

window.location.href = "index.php";
// connected
} else {
// cancelled
}
});
}

function testAPI() {
console.log('Welcome!  Fetching your information.... ');
FB.api('/me', function(response) {
//var myname = '+response.name+';
//alert(myname);
console.log('Good to see you, ' + response.name + '.');
});
}
</script>

<!-- FB LOGIN -->

The window.fbAsyncInit function is called as soon as the JavaScript SDK is loaded. Within that function you have placed your FB.getLoginStatus logic. What you'll want to do is take the FB.getLoginStatus out of window.fbAsyncInit and trigger it when the user clicks your login button.

function doLogin(){
  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
      // connected
    } else if (response.status === 'not_authorized') {
      // not_authorized
      login();
    } else {
      // not_logged_in
      login();
    }
  });
}


<button onclick="doLogin();">Login</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM