OK,我试图用Hybridauth与laravel 4。但是我似乎正在试图与Facebook登录的时候很常见:laravel4 hybridauth facebook验证失败! Facebook的返回一个无效的用户ID
Authentication failed! Facebook returned an invalid user id.
我已阅读全部其他职位,并没有运气,所以只希望有人能够帮助我。
我跟着这个教程:http://www.mrcasual.com/on/coding/laravel4-package-management-with-composer/
,并尝试其他几种配置,没有成功。
这里是我的配置/ hybridauth.php
<?php
return array(
"base_url" => "http://myapp.dev/social/auth/",
"providers" => array (
"Facebook" => array (
"enabled" => true,
"keys" => array ("id" => "****", "secret" => "****"),
),
),
);
这里是我的路线:
Route::get('social/{action?}', array("as" => "hybridauth", function($action = "")
{
// check URL segment
if ($action == "auth") {
// process authentication
try {
Hybrid_Endpoint::process();
}
catch (Exception $e) {
// redirect back to http://URL/social/
return Redirect::route('hybridauth');
}
return;
}
try {
// create a HybridAuth object
$socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php');
// authenticate with Facebook
$provider = $socialAuth->authenticate("Facebook");
// fetch user profile
$userProfile = $provider->getUserProfile();
}
catch(Exception $e) {
// exception codes can be found on HybBridAuth's web site
return $e->getMessage();
}
// access user profile data
echo "Connected with: <b>{$provider->id}</b><br />";
echo "As: <b>{$userProfile->displayName}</b><br />";
echo "<pre>" . print_r($userProfile, true) . "</pre><br />";
// logout
$provider->logout();
}));
所以,当我访问 “myapp.dev/social” 我带来了Facebook注册页面everthing似乎工作正常,要求我允许myadd.dev的权限。点击确定后,我会看到以下URL:http://myapp.ie/social#_=_
显示错误。
不知道这是否与此相关: 仅通过观察其他合作Facebook登录的网站,重定向网址看起来像http://somesite.dev/subdomain/#_=_
。换句话说,他们在#=之前有斜线。这是我的问题,我该如何解决?非常新的hybridauth所以任何帮助非常感谢。
哦,我知道这篇文章与其他文章非常相似,但我还没有找到解决方案。
UPDATE:确切的错误:Authentification failed. The user has canceled the authentication or the provider refused the connection.
我注意到,这个问题只发生在Firefox(23.0.1胜)(至少对我来说)..可能是一些帮助 – OZZIE
面对同样的问题。我已经尝试了所有下面提到的事情,但仍然卡住!我分别测试了facebook-php-sdk(github.com/facebook/facebook-php-sdk)和那个例子。 –
尝试这里提到的解决方案http://stackoverflow.com/a/20000638/1154919 –