我目前正在uni中为我的项目实现社交帐户登录功能。
我已经通过编辑器安装了HybridAuth,并完全遵循HybridAuth网页上的指南。
我的代码:
...
else if (isset($_REQUEST["provider"])) {
// the selected provider
$provider_name = $_REQUEST["provider"]; // currently testing with only Facebook provider
try {
// initialize Hybrid_Auth class with the config file
require_once '../vendor/autoload.php';
$config = array(
"base_url" => 'http://localhost/project/vendor/hybridauth/hybridauth/hybridauth',
"providers" => array (
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "xxxxxxx", "secret" => "xxxxxxx" ),
"display" => "popup" // optional
)));
$hybridauth = new Hybrid_Auth($config);
// try to authenticate with the selected provider
$adapter = $hybridauth->authenticate($provider_name);
// then grab the user profile
$user_profile = $adapter->getUserProfile();
echo $user_profile->displayName;
}
(Exception $e) {
....}
...
但后来我收到了这个错误,并没有将我重定向到Facebook认证页面:
Auth.php中的第367行:
if ($mode == "PHP") {header("Location: $url");}
任何指针?