我正在嘗試使HybridAuth社交登錄(版本2.6.0)在這個簡單的PHP網站上工作。下載HybridAuth並安裝它。 每當我點擊鏈接登錄社交網絡(Facebook),它都會將我重定向到(MY_BASE_URL/index.php?hauth.start = Facebook & hauth.time),而不會顯示任何登錄窗口/錯誤消息。HybridAuth:重定向後如何獲取用戶信息
下面是聯接該文件:
$config ="../hybridauth/config.php";
require_once("../hybridauth/Hybrid/Auth.php");
try{$hybridauth = new Hybrid_Auth($config);
$provider = @ trim(strip_tags($_GET["provider"]));
$adapter = $hybridauth->authenticate($provider);
$adapter = $hybridauth->getAdapter($provider);
$user_data = $adapter->getUserProfile();
if($user_data)
{
print_r($user_data);
}
else
{
echo '******* CRASH *******';
exit;
}
}
catch(Exception $e){
switch($e->getCode()){
case 0 : echo "Unspecified error."; break;
case 1 : echo "Hybriauth configuration error."; break;
case 2 : echo "Provider not properly configured."; break;
case 3 : echo "Unknown or disabled provider."; break;
case 4 : echo "Missing provider application credentials."; break;
case 5 : echo "Authentication failed. "
. "The user has canceled the authentication or the provider refused the connection.";
case 6 : echo "User profile request failed. Most likely the user is not connected "
. "to the provider and he should to authenticate again.";
$adapter->logout();
break;
case 7 : echo "User not connected to the provider.";
$adapter->logout();
break;
}
echo "<b>Original error message:</b> " . $e->getMessage();
echo "<hr /><h3>Trace</h3> <pre>" . $e->getTraceAsString() . "</pre>";
}
這裏是配置文件:
return
array(
"base_url" => "http://woonmako.com/hybridauth/index.php",
"providers" => array(
"Google" => array(
"enabled" => true,
"keys" => array("id" => "", "secret" => ""),
),
"Facebook" => array(
"enabled" => true,
"keys" => array("id" => "*********", "secret" => "***********"),
"trustForwarded" => false
),
"Twitter" => array(
"enabled" => true,
"keys" => array("key" => "", "secret" => ""),
"includeEmail" => false
),
),
"debug_mode" => false,
"debug_file" => "",
);
我想知道它是如何工作的以及在哪個文件中我必須獲取用戶信息。