2

ここのチュートリアルに従って、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 サイト URL: 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
4

3 に答える 3

3

Try removing the trailing slash on your hybridauth.php base_url. Works for me. Answer provided by @MrCasual here

于 2013-06-26T04:43:47.893 に答える
1

次のように変更base_urlします。

URL::route('hybridauth', array('action' => 'auth'));
于 2013-06-26T10:31:48.590 に答える
0

[解決策] 末尾のスラッシュを削除:

于 2013-08-25T12:54:46.013 に答える