Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Linkedin.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 2.94 KiB


001  <?php
002   
003  namespace OAuth\OAuth2\Service;
004   
005  use OAuth\OAuth2\Token\StdOAuth2Token;
006  use OAuth\Common\Http\Exception\TokenResponseException;
007  use OAuth\Common\Http\Uri\Uri;
008  use OAuth\Common\Consumer\CredentialsInterface;
009  use OAuth\Common\Http\Client\ClientInterface;
010  use OAuth\Common\Storage\TokenStorageInterface;
011  use OAuth\Common\Http\Uri\UriInterface;
012   
013  /**
014   * Linkedin service.
015   *
016   * @author Antoine Corcy <contact@sbin.dk>
017   * @link http://developer.linkedin.com/documents/authentication
018   */
019  class Linkedin extends AbstractService
020  {
021      /**
022       * Defined scopes
023       * @link http://developer.linkedin.com/documents/authentication#granting
024       */
025      const SCOPE_R_BASICPROFILE      = 'r_basicprofile';
026      const SCOPE_R_FULLPROFILE       = 'r_fullprofile';
027      const SCOPE_R_EMAILADDRESS      = 'r_emailaddress';
028      const SCOPE_R_NETWORK           = 'r_network';
029      const SCOPE_R_CONTACTINFO       = 'r_contactinfo';
030      const SCOPE_RW_NUS              = 'rw_nus';
031      const SCOPE_RW_COMPANY_ADMIN    = 'rw_company_admin';
032      const SCOPE_RW_GROUPS           = 'rw_groups';
033      const SCOPE_W_MESSAGES          = 'w_messages';
034      const SCOPE_W_SHARE             = 'w_share';
035   
036      public function __construct(
037          CredentialsInterface $credentials,
038          ClientInterface $httpClient,
039          TokenStorageInterface $storage,
040          $scopes = array(),
041          UriInterface $baseApiUri = null
042      ) {
043          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
044   
045          if (null === $baseApiUri) {
046              $this->baseApiUri = new Uri('https://api.linkedin.com/v1/');
047          }
048      }
049   
050      /**
051       * {@inheritdoc}
052       */
053      public function getAuthorizationEndpoint()
054      {
055          return new Uri('https://www.linkedin.com/uas/oauth2/authorization');
056      }
057   
058      /**
059       * {@inheritdoc}
060       */
061      public function getAccessTokenEndpoint()
062      {
063          return new Uri('https://www.linkedin.com/uas/oauth2/accessToken');
064      }
065   
066      /**
067       * {@inheritdoc}
068       */
069      protected function getAuthorizationMethod()
070      {
071          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
072      }
073   
074      /**
075       * {@inheritdoc}
076       */
077      protected function parseAccessTokenResponse($responseBody)
078      {
079          $data = json_decode($responseBody, true);
080   
081          if (null === $data || !is_array($data)) {
082              throw new TokenResponseException('Unable to parse response.');
083          } elseif (isset($data['error'])) {
084              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
085          }
086   
087          $token = new StdOAuth2Token();
088          $token->setAccessToken($data['access_token']);
089          $token->setLifeTime($data['expires_in']);
090   
091          if (isset($data['refresh_token'])) {
092              $token->setRefreshToken($data['refresh_token']);
093              unset($data['refresh_token']);
094          }
095   
096          unset($data['access_token']);
097          unset($data['expires_in']);
098   
099          $token->setExtraParams($data);
100   
101          return $token;
102      }
103  }
104