我对 Facebook 连接有一点问题,关于生日许可。
在我的 html 正文上:
<div class="fb-login-button" scope="user_birthday, user_about_me" perms="email,user_birthday"> Login with Facebook </div>
在标题上,对于 jS,我有:
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXX', // App ID
channelUrl : '//connect.facebook.net/en_US/all.js', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional init code here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
FB.api('/me??accessToken='+response.authResponse.accessToken, function(user) {
var monthfb = user.birthday.substr(0,2);
var dayfb = user.birthday.substr(3,2);
var yearfb = user.birthday.substr(6,4);
$("input[id=year]").val(monthfb);
$("input[id=month]").val(dayfb);
$("input[id=day]").val(yearfb);
$("a.age_gate_submit").click();
alert('1');
console.log(user);
//$.cookie('age_gate', 'gohome',{ expires: 99 });
window.location = "home.html";
});
}
});
};
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
FB.api('/me??accessToken='+response.authResponse.accessToken, function(user) {
var monthfb = user.birthday.substr(0,2);
var dayfb = user.birthday.substr(3,2);
var yearfb = user.birthday.substr(6,4);
$("a.age_gate_submit").click();
alert('2');
//console.log(response.birthday);
console.log(user);
//$.cookie('age_gate', 'gohome',{ expires: 99 });
window.location = "home.html";
});
}
});
}
// 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#xfbml=1&appId=XXXXXXX";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
当我点击我的按钮时,我有一个好的窗口,我接受了 FB 应用程序,但是 jS 没有调用任何函数,所以 window.locations 不起作用。但是我刷新没关系,我可以过生日等等......所以问题就在我接受应用程序的那一刻:请如何重定向?