【发布时间】:2014-10-31 07:50:13
【问题描述】:
我已将 hybridauth 与 laravel 集成,并且能够使用 hybridauth 通过 twitter 登录我的应用程序。当我第一次使用 twitter 登录我的应用程序时,我已经授权了我的应用程序。所以,一般来说,下次我不需要授权我的应用程序登录,因为我第一次接受了授权。
但它没有发生。每次我尝试登录 Twitter 时,我的应用程序都必须通过 twitter 授权。
我正在本地主机上尝试这个。我需要在实时服务器中检查它吗?
我正在使用此代码,所有凭据都已设置:
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 Google
$provider = $socialAuth->authenticate("Twitter");
// 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();
}));
【问题讨论】:
标签: twitter laravel localhost hybridauth