Can someone tell me how the FB API works. This seems like a basic question, but I'm really confused.
Question: I have onlogin (). When I press the login button, I expect it to call this function. But in the code I pasted: I see that the test test first prints and FB.api is called.
So it looks like onlogin is being called first, then the FB API ... there is a way that I can call this function only once.
<body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: 'XXX', status: true, cookie: true, xfbml: true}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); function checkFacebookLogin() { FB.api('/me', function(response) { alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id); }); alert('test'); } </script> <p id="fb_login_button_1"><fb:login-button onlogin="checkFacebookLogin();" size="medium" scope="user_about_me">Sign in using Facebook</fb:login-button></p> </body>v
My main problem is that the function should be called only once .... but it is called twice.
The learningner
source share