Set callback url for Facebook login button
I'm starting to work with FB integration on my website and I've found that Facebook's documentation isn't that great.
I want to create a login button on my page and then handle the response on the server side but I cannot seem to find a good way to do that.
I'm using the XFBML tag, but the only event I know of is the "onlogin" (which by the way, I cannot find in the documentation), which allows me to set a javascript function as callback, the problem there is that I would have to call FB.getLoginStatus to get the logged in info and then redirect the user to the page I want and also manually pass the logged in user's info in the query string.
e.g. Put this code on the onlogin callback function
FB.getLoginStatus(function(response) {
if (response.session) {
window.location.replace('/Account/ProcessFbLogin?uid=' + resp开发者_如何学运维onse.session.uid ...');
}
}
I think there should be a better way to do this, but I just cannot find it.
Thanks
A better way can be the OAuth Dialog where you can specify the redirect_uri
parameter.
check out SocialAuth...super cool and easy to use!
精彩评论