I’m displaying the requests dialog multi with JS SDK when the user clicks the login with Facebook button on my site. Now I want to redirect the user after he/she sends the invite or cancels the request dialog so I can then proceed to signing him or her in the site.
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));
}
So i think manage to get it with this code:
I used the callback function(response) to trigger the sendUserToLoginProcess() which then proceeds to redirect and signin the user. But I’m not really using the response variable so I hope that’s just ok.