Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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:58 - Dateigröße: 3.12 KiB


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