Skip to content

Latest commit

 

History

History
76 lines (64 loc) · 2.09 KB

README.md

File metadata and controls

76 lines (64 loc) · 2.09 KB

Kohana Socialite

The Kohana Socialite module provides an expressive, fluent interface to OAuth authentication.

Getting Started

  1. Download the module into your modules subdirectory.
  2. Enable the module in your bootstrap file:
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
// ...
  'socialite'       => MODPATH.'socialite',
));
  1. Make sure the settings in config/socialite.php are correct for your environment. If not, copy the file to application/config/socialite.php and change the values accordingly.

Usage

class Controller_Auth extends Controller
{
    public function action_login()
    {
        $socialite = Socialite::factory()
            ->driver('Facebook')
            ->redirect_url(Route::url('auth', array('action' => 'callback',)));

        $socialite->redirect();
    }

    public function action_callback()
    {
        $socialite = Socialite::factory()
            ->driver('Facebook')
            ->redirect_url(Route::url('auth', array('action' => 'callback',)));
        
        try 
        {
            $user = $socialite->user();
        } 
        catch (Socialite_Exception $e) 
        {
            throw new Kohana_Exception($e->getMessage());
        }
        
        // Retrieving User Details
        $id = $user->get_id();
        $nickname = $user->get_nickname();
        $first_name = $user->get_first_name();
        $surname = $user->get_surname();
        $birthday = $user->get_birthday();
        $gender = $user->get_gender();
        $photo = $user->get_photo();
        $email = $user->get_email();
        $phone = $user->get_phone();
        $website = $user->get_website();
        $profile = $user->get_profile();
    }
}

Providers

  • Facebook
  • Instagram
  • Mail
  • Odnoklassniki
  • Vkontakte

Acknowledgements

The author drew extensive inspiration from the Laravel Socialite package and its related documentation.

License

This package is open-sourced software licensed under the MIT license