我已经在我的Web应用程序中实现了Facebook Login。它工作正常,但不显示登录时间“权限”对话框。
window.fbAsyncInit = function() {
FB.init({
appId : '',
oauth: true,
autoLogAppEvents : true,
xfbml : true,
version : ''
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//console.log('connected');
//document.getElementById('status').innerHTML = 'We are connected.';
//document.getElementById('loginFbBtn').style.visibility = 'hidden';
//getInfo();
} else if (response.status === 'not_authorized') {
// console.log('not_authorized');
//document.getElementById('status').innerHTML = 'We are not logged in.'
} else {
// console.log('not logged into Facebook');
//document.getElementById('status').innerHTML = 'You are not logged into Facebookfccvyh.';
}
});
};
(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'));
function fbRegistration() {
FB.getLoginStatus(function(response) {
//console.log(response);
if (response && response.status === 'connected') {
}else{
FB.login(function(response) {
showLoader();
if (response.status === 'connected') {
FB.api('/me', 'GET', {fields: 'first_name,last_name,name,id,email,gender,birthday,picture.width(150).height(150)'}, function(response) {
if(response.gender === 'male'){
window.location.href = BASE_URL + 'Home/registration?response=3';
return false;
}
//document.getElementById('status').innerHTML = "<img src='" + response.picture.data.url + "'>";
$.ajax({
type: 'POST',
data: {firstName:response.first_name,lastName:response.last_name,fbUserId:response.id,email:response.email,dob:response.birthday,imageUrl: response.picture.data.url},
url: BASE_URL + 'Home/fbRegistration',
success: function (result) {
hideLoader();
if (result === '1') {
window.location.href = BASE_URL + 'Home/myProfile';
} else if (result === '2') {
window.location.href = BASE_URL + 'Home/registration?response=2';
}
}
});
});
} else if (response.status === 'not_authorized') {
//document.getElementById('status').innerHTML = 'We are not logged in.'
} else {
//document.getElementById('status').innerHTML = 'You are not logged into Facebook.';
}
}, {scope: 'email',auth_type: 'rerequest'});
}
});
}