Hola tengo un problema con facebook conect y con el login, estoy trabajando con un script, pero me dice que para iniciar sesion con facebook solo modifique u archivo que les dejare a continuacion y meta el app id y el app secret que me proporciona facebook, lo hago y todo bien, despues le doy en el boton que me dice, iniciar sesion con facebook y todo normal te manda a facebook e inicias sesion, pero cuando me regresa a mi pagina web, chrome me suelta un error que dice "esta pagina web tiene un bucle de reedireccion" alguien sabe solucionarlo? aqui les dejo el codigo que les menciono
Código:
<?php
/*!
* QAScript v1.2.0
* http://ifsoft.com.ua
* [email protected]
*
* Copyright (C) 2012-2014 Demyanchuk Dmitriy (Russian Dimon)
*/
Class facebook extends db_connect {
static protected $oAppId = ""; //APP ID
static protected $oAppSecret = ""; //APP SECRET
static protected $oRedirectUri = "http://demo.ifsoft.com.ua/login/?action=facebook";
static protected $oCode = NULL;
static protected $oInstance = NULL;
public function __construct($dbo=NULL)
{
parent::__construct($dbo);
}
protected function getCode()
{
if(isset($_REQUEST["code"]))
{
self::$oCode = $_REQUEST["code"];
}
}
public function getLink()
{
$this->getCode();
if(!self::$oCode)
{
$_SESSION['state'] = md5(uniqid(rand(), TRUE));
$oDialogUrl = "http://www.facebook.com/dialog/oauth?client_id=" . self::$oAppId . "&redirect_uri=" . urlencode(self::$oRedirectUri) . "&state=" . $_SESSION["state"];
return $oDialogUrl;
}
}
public function logIn() {
if (!isset($_REQUEST['error'])) {
if(isset($_REQUEST['state']) and isset($_SESSION['state'])) {
if($_REQUEST['state'] == $_SESSION['state']) {
$this->getCode();
$tokenUrl = "https://graph.facebook.com/oauth/access_token?client_id=" . self::$oAppId . "&redirect_uri=" . urlencode(self::$oRedirectUri) . "&client_secret=" . self::$oAppSecret . "&code=" . self::$oCode;
$oResponse = @file_get_contents($tokenUrl);
$params = NULL;
parse_str($oResponse, $params);
$graphUrl = "https://graph.facebook.com/me?access_token=" . $params['access_token'];
$oUser = json_decode(@file_get_contents($graphUrl));
$app = new app($this->db);
$app->fbLogin($oUser->id, $oUser->first_name, $oUser->last_name, $oUser->username);
unset($app);
header("Location: /login/?status=success_fb_login");
}
} else {
// echo 'Error. $_REQUEST[\'state\'] or $_SESSION[\'state\'] is not available';
header("Location: /login/?status=error_fb_login");
}
} else {
header("Location: /login/?status=error_fb_login");
}
}
}
?>