phplaravel-5hybridauth

Integration of hybrid_auth in laravel 5


I am new to laravel framework any help would appreciate

When i try to execute the below code i get this error FatalErrorException in SocialController.php line 27: Class 'App\Http\Controllers\Hybrid_Auth' not found in SocialController.php line 27

when i remove the namespace from SocialController.php i get this error saying BaseController not found.

onclick this button

 <a href="{{action("SocialController@getFacebookLogin")}}" class="submit-button btn btn-block btn-primary"><i class="fa fa-facebook"></i>&nbsp;&nbsp;Facebook</a>

SocialController.php

       <?php
        namespace App\Http\Controllers;
        use App\Http\Controllers\Controller; 
        use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

    class SocialController extends BaseController
    {


//this is the code for facebook Login
public function getFacebookLogin($auth=NULL)
{
    if ($auth == 'auth')
    {
        try
        {
            Hybrid_Endpoint::process();
        }
        catch (Exception $e)
        {
            return Redirect::to('fbauth');
        }
        return;
    }

    $oauth = new Hybrid_Auth(app_path(). '/config/fb_auth.php');
    $provider = $oauth->authenticate('Facebook');
    $profile = $provider->getUserProfile();
    return var_dump($profile).'<a href="logout">Log Out</a>';
}



   public function getLoggedOut()
{
    $fauth = new Hybrid_auth(app_path().'/config/fb_auth.php');
    $fauth->logoutAllProviders();
    return view::make('/');
}


 }

fb_auth.php

    <?php

   return array(
   "base_url" => "http://urmk.com/fbauth/auth",
   "providers" => array (
  "Facebook" => array (
  "enabled" => true,
  "keys"    => array ( "id" => "APP_ID", "secret" =>  "APP_SECRET" ),
  "scope"   => "email"
)
    )
     );

Routes.php

    Route::get('fbauth/{auth?}' ,array('as'=>'facebook',   'uses'=>'SocialController@getFacebookLogin'));                                                                                                          
    Route::get('logout',array('as'=>'logout','uses'=>'SocialController@getLoggedOut'));

Solution

  • You will need to add the namespace to your Hybrid Auth class. At the moment, when you are trying to instantiate the Hybrid_Auth object, it's not finding the class definition.