FB Connect going in endless loop with google chrome


I have the following php code that I am trying to test FB Connect

<?php define('FACEBOOK_APP_ID', 'YOUR_APP_ID'); define('FACEBOOK_SECRET', 'YOUR_APP_SECRET'); 

function get_facebook_cookie($app_id, $application_secret) { enter code here $args = array(); parse_str(trim($COOKIE['fbs' . $app_id], '\"'), $args); ksort($args); $payload = ''; foreach ($args as $key => $value) { if ($key != 'sig') { $payload .= $key . '=' . $value; } } if (md5($payload . $application_secret) != $args['sig']) { return null; } return $args; } $cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET); ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <body>
<?php if ($cookie) { ?> Your user ID is <?= $cookie['uid'] ?> <br /> Your Acess Token is <br /> <?php
$user = json_decode(file_get_contents( 'https://graph.facebook.com/me?access_token=' . $cookie['access_token'])); if($user) { echo "<br />Display Name = " . $user->name; echo "<br />First Name = " . $user->first_name; echo "<br />Last Name = " . $user->last_name; echo "<br />Birthday = " . $user->birthday; echo "<br />Home Town = " . $user->hometown->name; echo "<br />Location = " . $user->location->name; echo "<br />Email = " . $user->email . "<br />"; } ?> <?php } else { ?> <fb:login-button perms="email,user_birthday,publish_stream"></fb:login-button> <?php } ?>

 <div id="fb-root">&lt;/div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({appId: '<?= FACEBOOK_APP_ID ?>', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('auth.login', function(response) { window.location.reload(); }); </script> 

</> </HTML>

code>

The problem I ran into is working well with IE and Firefox, but when everything is done the same with google chrome, I start an endless loop when I press the Chrome reboot / update button after logging in.


Any hints as to why this happens with chrome? Just like this can be avoided.


Thanks,
Mitesh
+4
source share
2 answers

Must work.

 <div id="fb-root"></div> <script type="text/javascript"> window.fbAsyncInit = function () { FB.init({ appId: 'APP_ID', status: true, cookie: true, xfbml: true }); FB.Event.subscribe('auth.login', function () { window.location.reload() }) }; (function () { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e) }()); </script> 
0
source

this code

 FB.Event.subscribe('auth.login', function(response) { window.location.reload(); }); 

I think this is a problem, try removing it. I really don’t need it because I use it and it automatically updates once upon login

 FB.login(function(response) { if(response.session) { window.location.reload(); } },{perms:'email,user_birthday,user_hometown,user_location'}); 
0
source

Source: https://habr.com/ru/post/1333016/


All Articles