Please, I need some help. I have been dealing with this problem for 1 month!
I would like to use login to enter my site using PHP and php-sdk 3.1.1. In a few words, my code works offline (on the local host), but not on the network, which leads to "Too many redirect cycles (in Chrome)": Error 310 (net :: ERR_TOO_MANY_REDIRECTS): there were too many redirects.
Here is my code:
1 / I load facebook by connecting the SDK and initializing it:
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => '209633612480053',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
));
Please note that I created two applications on the facebook-developper page, one for offline tests, and the other for online tests. And I'm sure it’s correct to switch between two pairs of appId / secret (online and offline) when testing. So this is not a bad facebbok-connect init problem.
2 / I'm trying to get user information:
$uid = $facebook->getUser();
if($uid)
{
$user = $facebook->api('me/');
print_r($user);
}
else
{
$loginURL = $facebook->getLoginURL();
echo '<script> top.location.href=\''.$loginURL.'\'</script>';
}
It is so simple: if user ic is connected to facebook, display it like that; otherwise, go to the facebook login page to allow access.
THIS WORKS PERFECTLY IN OFF, but online, I get a chrome error:
This webpage has a redirect loop
The webpage at https://www.facebook.com/dialog/oauth?client_id=209633612480053&redirect_uri=http%3A%2F%2Fwww.bluward.com%2Foauth%2Ffacebook&state=551f60cd4be6cd8ed1622f8168a5219a
Additional information: online, I use host provider 1 and 1 and, of course, have the same server configuration as the stand-alone server (which is MAMP Pro), I downloaded the sams php.ini file.
Please, if someone has an idea or has a similar problem, I will be happy to receive help.
Thank you in advance for your help.
UPDATE:
I updated my code to focus on the problematic line, so instead of redirecting to the facebook login page, I display the redirect URL, so I just need to click to log in:
$uid = $facebook->getUser();
if($uid)
{
$user = $facebook->api('me/');
print_r($user);
}
else
{
$loginURL = $facebook->getLoginURL();
echo $loginURL;
}
, , facebook script. code URL.
, facebbok script, ?
, ?