php - Problems with Facebook login on localhost -
i'm using yii eauth plugin logging social networks , works on prod server. i'm having problem making work on local developer machine.
i don't user http://localhost, http://my-domain.com
i've created fb called myapp local, i'm unsure add in app domains
, site url
.
when login, fb pop-up dialogue url looks this:
https://www.facebook.com/dialog/oauth?client_id=12345678901515987&redirect_uri=http%3a%2f%2fmy-domain.com%2flogin%3fservice%3dfacebook&scope=email,%20public_profile,%20user_friends&response_type=code
but nothing happens , i'm redirected login page.
know i'm doing wrong?
update
js code localhost currently:
(this placed in header)
window.fbasyncinit = function() { fb.init({ appid : '12345678901515987', xfbml : true, version : 'v2.3' }); }; (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/sdk.js"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
the additional js code can find in source code (generated yii eauth) this:
/*<![cdata[*/ jquery(function($) { $(".auth-service.facebook a").eauth({"popup":{"width":585,"height":290},"id":"facebook"}); }); /*]]>*/
here solution, works fine on localhost.
you see in code line :
window.location.href = "/webuser/account/fblogin";
the url "/webuser/account/fblogin" controller action creates user session , configures user logged in
<div id="fb-root"></div> <script type="text/javascript"> window.fbasyncinit = function() { fb.init({ appid: '1234567890', // replace app id here channelurl: 'https://www.facebook.com/your_fb_url', status: true, cookie: true, xfbml: true }); }; (function(d) { var js, id = 'facebook-jssdk', ref = d.getelementsbytagname('script')[0]; if (d.getelementbyid(id)) { return; } js = d.createelement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_us/all.js"; ref.parentnode.insertbefore(js, ref); }(document)); function fblogin() { fb.login(function(response) { if (response.authresponse) { window.location.href = "/webuser/account/fblogin"; } }, {scope: 'email,publish_actions,user_birthday,user_location,user_work_history'}); } $(document).ready(function(){ $('#login-facebook').click(function(event){ event.preventdefault() fblogin(); return false; }); }); </script>
Comments
Post a Comment