当用户点击我网站上的Facebook按钮登录时,我正在使用JS SDK显示请求对话框。现在我想在用户发送邀请或取消请求对话框后重定向用户,以便我可以继续在网站上签名。
button = document.getElementById('fbc-login-button');
button.onclick = function() {
FB.getLoginStatus(function(response) {
if (response.authResponse) {
sendRequestViaMultiFriendSelector(response.authResponse.accessToken);
}
else {
FB.login(function(response) {
if (response.authResponse) {
sendRequestViaMultiFriendSelector(response.authResponse.accessToken);
}}, {scope: 'email'});
}
});
};
function sendUserToLoginProcess(accessToken){
var fb_signin_url = '<?php echo CustomLocal_Resource_Url_Process::userSignin() ?>?command=<?php echo CustomLocal_Logic_Customer_User::COMMAND_FB_SIGNIN ?>&url_redirect=<?php echo Custom_Resource_Url_Customer::main(); ?>&url_redirect_fail=<?php echo Custom_Resource_Url_Customer::signin(); ?>';
this.location = fb_signin_url + '&token=' + accessToken;
};
function sendRequestViaMultiFriendSelector(accessToken) {
FB.ui({method: 'apprequests',
message: 'My Great Request'
}, sendUserToLoginProcess(accessToken));
}
答案 0 :(得分:0)
所以我认为设法使用此代码:
button = document.getElementById('fbc-login-button');
button.onclick = function() {
FB.getLoginStatus(function(response) {
if (response.authResponse) {
sendRequestViaMultiFriendSelector(response.authResponse.accessToken);
}
else {
FB.login(function(response) {
if (response.authResponse) {
sendRequestViaMultiFriendSelector(response.authResponse.accessToken);
}}, {scope: 'email'});
}
});
};
function sendUserToLoginProcess(accessToken){
var fb_signin_url = '<?php echo CustomLocal_Resource_Url_Process::userSignin() ?>?command=<?php echo CustomLocal_Logic_Customer_User::COMMAND_FB_SIGNIN ?>&url_redirect=<?php echo Custom_Resource_Url_Customer::main(); ?>&url_redirect_fail=<?php echo Custom_Resource_Url_Customer::signin(); ?>';
this.location = fb_signin_url + '&token=' + accessToken;
};
function sendRequestViaMultiFriendSelector(accessToken) {
FB.ui({method: 'apprequests',
message: 'Shop with me!'
},
function(response)
{
sendUserToLoginProcess(accessToken)
});
}
我使用回调函数(响应)来触发sendUserToLoginProcess(),然后继续重定向并注册用户。但我并没有真正使用响应变量,所以我希望这没关系。