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

Dropbox.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.28 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   * Dropbox service.
 014   *
 015   * @author Flávio Heleno <flaviohbatista@gmail.com>
 016   * @link https://www.dropbox.com/developers/core/docs
 017   */
 018  class Dropbox extends AbstractService
 019  {
 020   
 021      public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 022      {
 023          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
 024          if( null === $baseApiUri ) {
 025              $this->baseApiUri = new Uri('https://api.dropbox.com/1/');
 026          }
 027      }
 028   
 029      /**
 030       * Returns the url to redirect to for authorization purposes.
 031       *
 032       * @param array $additionalParameters
 033       * @return string
 034       */
 035      public function getAuthorizationUri( array $additionalParameters = array() )
 036      {
 037          $parameters = array_merge($additionalParameters, array(
 038              'client_id'     => $this->credentials->getConsumerId(),
 039              'redirect_uri'  => $this->credentials->getCallbackUrl(),
 040              'response_type' => 'code',
 041          ));
 042   
 043          $parameters['scope'] = implode(' ', $this->scopes);
 044   
 045          // Build the url
 046          $url = clone $this->getAuthorizationEndpoint();
 047          foreach($parameters as $key => $val)
 048          {
 049              $url->addToQuery($key, $val);
 050          }
 051   
 052          return $url;
 053      }
 054   
 055      /**
 056       * @return \OAuth\Common\Http\Uri\UriInterface
 057       */
 058      public function getAuthorizationEndpoint()
 059      {
 060          return new Uri('https://www.dropbox.com/1/oauth2/authorize');
 061      }
 062   
 063      /**
 064       * @return \OAuth\Common\Http\Uri\UriInterface
 065       */
 066      public function getAccessTokenEndpoint()
 067      {
 068          return new Uri('https://api.dropbox.com/1/oauth2/token');
 069      }
 070   
 071      /**
 072       * Returns a class constant from ServiceInterface defining the authorization method used for the API
 073       * Header is the sane default.
 074       *
 075       * @return int
 076       */
 077      protected function getAuthorizationMethod()
 078      {
 079          return static::AUTHORIZATION_METHOD_QUERY_STRING_V2;
 080      }
 081   
 082      /**
 083       * @param string $responseBody
 084       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth2\Token\StdOAuth2Token
 085       * @throws \OAuth\Common\Http\Exception\TokenResponseException
 086       */
 087      protected function parseAccessTokenResponse($responseBody)
 088      {
 089          $data = json_decode( $responseBody, true );
 090   
 091          if( null === $data || !is_array($data) ) {
 092              throw new TokenResponseException('Unable to parse response.');
 093          } elseif( isset($data['error'] ) ) {
 094              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 095          }
 096   
 097          $token = new StdOAuth2Token();
 098   
 099          $token->setAccessToken( $data['access_token'] );
 100   
 101          if( isset($data['refresh_token'] ) ) {
 102              $token->setRefreshToken( $data['refresh_token'] );
 103              unset($data['refresh_token']);
 104          }
 105   
 106          unset( $data['access_token'] );
 107          $token->setExtraParams( $data );
 108   
 109          return $token;
 110      }
 111  }
 112