2017 © Pedro Peláez
 

library linkedin-nette

LinkedIn authorization for Nette framework

image

fabian/linkedin-nette

LinkedIn authorization for Nette framework

  • Tuesday, October 21, 2014
  • by fabiancz
  • Repository
  • 5 Watchers
  • 9 Stars
  • 186 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 4 Open issues
  • 1 Versions
  • 42 % Grown

The README.md

Instalation

The best way is via Composer:, (*1)

composer require fabian/linkedin-nette:dev-master

Usage

linkedin:
    appId: "YOUR_API_KEY"
    appSecret: "YOUR_API_SECRET"
    permissions: [r_fullprofile, r_emailaddress]

and extension:, (*2)

extensions:
    linkedin: \Fabian\Linkedin\LinkedinExtension
  • in your BasePresenter inject LinkedIn extension:
/**
 * @var \Fabian\Linkedin\Linkedin
 */
private $linkedin;

public function __construct(\Fabian\Linkedin\Linkedin $linkedin)
{
    parent::__construct();
    $this->linkedin = $linkedin;
}
  • and create component handling login operations:
protected function createComponentLinkedinLogin()
{
    $dialog = $this->linkedin->createDialog();
    /** @var \Fabian\Linkedin\LoginDialog $dialog */

    $dialog->onResponse[] = function(\Fabian\Linkedin\LoginDialog $dialog) {
        $me = $this->linkedin->call(
            'people/~:(id,first-name,last-name,email-address)'
        );

        // if user is not found in your database, register new based on LinkedIn profile details
        if (!$existing = $this->usersModel->findByLinkedinId($me->id)) {
            $existing = $this->usersModel->registerFromLinkedin((array) $me);
        }

        $this->user->login(new \Nette\Security\Identity($existing->users_id, $existing->role, $existing));
    };

    return $dialog;
}
  • place LinkedIn login in your template:
<a n:href="linkedinLogin-open!">Login by LinkedIn</a>

Inspired by Kdyby\Facebook, (*3)

The Versions

21/10 2014

dev-master

9999999-dev

LinkedIn authorization for Nette framework

  Sources   Download

MIT

The Requires

 

api authorization login nette linkedin