2017 © Pedro Peláez
 

library socialogin

enable facebook,twitter and google user login into Laravel powered site

image

enuke/socialogin

enable facebook,twitter and google user login into Laravel powered site

  • Saturday, August 2, 2014
  • by kamaljitenuke
  • Repository
  • 1 Watchers
  • 2 Stars
  • 329 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

enuke-social

Social login package laravel, (*1)

Installation Note, (*2)

Package Installation:, (*3)

1)composer.json and add below code, (*4)

"require": {
    -- -- -- -- -- --
            "enuke/socialogin": "dev-master"
},

2)app/config/app.php, (*5)

'providers' => array(
    -- -- -- -- -- --
            'Enuke\Socialogin\SocialoginServiceProvider',

),

'aliases' => array(
    -- -- -- -- -- --
            'Socialogin'      => 'Enuke\Socialogin\SocialoginFacade',
),

3) From your project terminal, (*6)

composer update

4) run php artisan config:publish enuke/socialogin and change the configuration in app/config/packages/enuke/socailogin/config.php, (*7)

5) paste the below line in your view, (*8)

<a href="/login?type=facebook">Login with Facebook</a><a href="/login?type=twitter">Login with Twitter</a>
<a href="/login?type=google">Login with Google</a>

Note: don't change the type param.

6)In your route place, (*9)

//package configuration file
$config = \Config::get("socialogin::config");

//OAuth response. Set your redirect url in vendor/enuke/socialogin/src/config/config.php
Route::get($config['redirect'], function() {

    //get OAuth provider name store in session 
    $oauth_provider = Session::get('oauth_provider');

    if (!Session::has('oauth_provider'))
    {
        die('Invalid Access');
    }


    if ( $oauth_provider == 'facebook' ) {  
        $code = Input::get('code');
        if (strlen($code) == 0) die('There was an error communicating with Facebook');
        $uid = Socialogin::getUser();
        if ($uid == 0) die('There was an error');
        $data = Socialogin::api('/me');

    }  else if ( $oauth_provider == 'google' ) {
        $google = new Enuke\Socialogin\Google;
        $data = $google->get_data();
        if ( empty($data) ) die('There was an error');
    } else if ( $oauth_provider == 'twitter' ){
        $twitter = new Enuke\Socialogin\Twitter;
        $data = $twitter->get_return();
        if ( empty($data) ) die('There was an error communicating with Twitter');
    }
    //Removing An Item From The Session
    Session::forget('key');
    //return data from Oauth provider
    print_r($data);
});

// login route 
Route::get('/login/', function() { 
    $type = Input::get('type');
    if (empty($type)){
        die('Invalid Access');
    }
    Session::put('oauth_provider', $type);

    if($type == 'facebook') {
        return Redirect::to(Socialogin::loginUrl());
    } else if ($type == 'twitter') {
        $twitter = new Enuke\Socialogin\Twitter;
        $check_connection = $twitter->login(); 
        if ( $check_connection ){
           return Redirect::to($check_connection);
        } else {
            die('Something Went Wrong');
        }
    } elseif ($type == 'google'){
        $google = new Enuke\Socialogin\Google;
        $url = $google->login();
        return Redirect::to($url); 
    } 
});

The Versions

02/08 2014

dev-master

9999999-dev https://github.com/kamaljitenuke/enuke-social

enable facebook,twitter and google user login into Laravel powered site

  Sources   Download

The Requires

 

by kamaljit

oauth socialogin enuke