use*_*871 5 facebook laravel hybridauth laravel-4
好吧,我正在尝试使用labrvel 4的Hybridauth.但是当我尝试使用facebook登录时,我似乎变得非常普遍:
验证失败!Facebook返回了无效的用户ID.
我已阅读所有其他帖子,并且没有运气,所以只是希望有人可以帮助我.
我遵循了这个教程:http://www.mrcasual.com/on/coding/laravel4-package-management-with-composer/
并尝试了其他几种配置,但没有成功.
这是我的config/hybridauth.php
<?php
return array(
"base_url" => "http://myapp.dev/social/auth/",
"providers" => array (
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "****", "secret" => "****" ),
),
),
);
Run Code Online (Sandbox Code Playgroud)
这是我的路线:
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();
}));
Run Code Online (Sandbox Code Playgroud)
因此,当我访问"myapp.dev/social"时,我被带到facebook注册页面,everthing似乎工作正常,要求我允许myadd.dev权限.单击"确定"后,我将转到以下URL:http://myapp.ie/social#_=_
显示错误的位置.
不确定这是否相关:只是观察其他合作Facebook登录的网站..重定向网址看起来像http://somesite.dev/subdomain/#_=_
.换句话说,他们在#=之前有一个斜杠.这是我的问题,我该如何解决?非常新的hybridauth所以任何帮助非常感谢谢谢.
哦,我确实意识到这篇文章与其他文章非常相似,但我还没有找到解决方案.
更新:确切的错误: Authentification failed. The user has canceled the authentication or the provider refused the connection.
在base_facebook.php中执行以下操作
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 50,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-3.2',
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
);
protected $trustForwarded = true;
protected $allowSignedRequest = false;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4971 次 |
最近记录: |