at the minute I have this:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
window.fbAsyncInit = function() {
FB.init({ appId:'188492754501683', cookie:true, status:true, xfbml:true });
};
</script>
<fb:login-button perms="email">
login with Facebook
</fb:login-button>
I want to run some code to pull the email aswell, say this:
FB.api('/me', function(res) { if (res != null) { alert(res.email); } } );
When I added this under the call to FB.init(), it was run as soon as the window loaded, which is understandable but not what I wanted.
I want the code to run AFTER the user has clicked the Login With Facebook button, and then successfully logged in, etc.
Can anyone point me in the right direction, I’ve searched google but can’t seem to find anything :/
Thanks in advance, Tom.
you can use the events for this:
see http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/ for more events you could subscribe to.
updated with full example