javascript - Facebook Login Button callback function -
i got problem facebook login on website. code below fb-connect code. commented part of code sign's me in website. problem when "reactivate" code logs me in instandly everytime visit page. want log user in when clicks "login facebook"-button. when clicks facebook login button popup shows , nothing happens..
can somehow call js function when click fb-connect button?
<script> window.fbasyncinit = function() { fb.init({ appid : 'xxxxxxxxxxxxxxxxxx', // app id status : true, cookie : true, xfbml : true, oauth : true, }); var login = false; fb.getloginstatus(function(response) { if (response.status === 'connected') { console.log('connected'); login=true; var uid = response.authresponse.userid; //this part of code below redircts me part, login system. /*var accesstoken = response.authresponse.accesstoken; $.ajax({ type: 'post', url: '/?eid=login', data: $(this).serialize(), success: function(msg) { alert("login"); $('#content').load('/live-session/tickets/'); } });*/ }});
you need use fb.login function on click on fb connect button , don't use fb.getloginstatus
fb.login(function(response) { if (response.authresponse) { console.log('welcome! fetching information.... '); fb.api('/me', function(response) { console.log('good see you, ' + response.name + '.'); }); } else { console.log('user cancelled login or did not authorize.'); } }); from doc
fb.getloginstatus allows determine if user logged in facebook , has authenticated app.
so, if don't want check whether user has logged in on page load, don't call
when clicks facebook login button popup shows , nothing happens..
if had authorized app , authenticated, facebook wont ask again login , authorization
Comments
Post a Comment