Exemple #1
0
 /**
  * @param array $config
  *
  * param example:
  *
  * private $config = [
  *   'app_key' => 'APP KEY',
  *   'app_secret' => 'APP SECRET',
  *   'access_token' => 'USER TOKEN'
  * ];
  *
  */
 public function __construct($config)
 {
     $serviceFactory = new \OAuth\ServiceFactory();
     $serviceFactory->setHttpClient(new CurlClient());
     $token = new StdOAuth2Token();
     $token->setAccessToken($config['access_token']);
     $storage = new Session();
     $storage->storeAccessToken('linkedin', $token);
     $redirectUrl = '';
     if (isset($_SERVER['HTTP_HOST'])) {
         $redirectUrl = $_SERVER['HTTP_HOST'];
     }
     $credentials = new Credentials($config['app_key'], $config['app_secret'], $redirectUrl);
     $this->service = $serviceFactory->createService('linkedin', $credentials, $storage, ['r_fullprofile', 'r_emailaddress', 'rw_nus']);
 }
Exemple #2
0
 /**
  * @return $this
  */
 public function destroySession()
 {
     $this->sessionStorage->clearToken($this->getServiceName());
     $this->sessionStorage->clearAuthorizationState($this->getServiceName());
     return $this;
 }