我正在尝试按照此处的教程设置 Facebook 登录:
http://www.mrcasual.com/on/coding/laravel4-package-management-with-composer/#additional_resources
我在本地服务器上运行我的网站(我设置了一个 dyndns 主机名,以便我的 Facebook 应用程序指向它)。这是我希望 Facebook 登录的页面:
http://mactest.dynalias.com:8888/crowdsets/laravel-master/public/fans/landing
在Facebook上:
应用域名:mactest.dynalias.com 网站网址:http ://mactest.dynalias.com
这是我的代码:
混合身份验证.php:
<?php
return array(
"base_url" => "http://mactest.dynalias.com:8888/crowdsets/laravel-master/public/fans/landing/auth/",
"providers" => array (
"Google" => array (
"enabled" => false,
"keys" => array ( "id" => "ID", "secret" => "SECRET" ),
),
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "***************", "secret" => "******************" ),
"scrop" => "first_name,last_name,email,user_birthday,gender,user_location,friends,
),
"Twitter" => array (
"enabled" => false,
"keys" => array ( "key" => "ID", "secret" => "SECRET" )
)
),
);
路线.php:
Route::get('fans/landing', array('uses' => 'GuestController@getIndex'));
Route::get('fans/landing/{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("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();
}));
在我看来:
<div id="facebook">
<span class="button-signin-facebook"><div class="facebook_connect_wrap small"><a href="?provider=Facebook">Sign up with Facebook</a></div></span>
</div>
当我单击 Facebook 按钮时,似乎什么也没发生,并且 URL 只是更改为:
http://mactest.dynalias.com:8888/crowdsets/laravel-master/public/fans/landing?provider=Facebook