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

Vimeo.php

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


001  <?php
002  /**
003   * Vimeo service.
004   *
005   * @author  Pedro Amorim <contact@pamorim.fr>
006   * @license http://www.opensource.org/licenses/mit-license.html MIT License
007   * @link    https://developer.vimeo.com/
008   * @link    https://developer.vimeo.com/api/authentication
009   */
010   
011  namespace OAuth\OAuth2\Service;
012   
013  use OAuth\OAuth2\Token\StdOAuth2Token;
014  use OAuth\Common\Http\Exception\TokenResponseException;
015  use OAuth\Common\Http\Uri\Uri;
016  use OAuth\Common\Consumer\CredentialsInterface;
017  use OAuth\Common\Http\Client\ClientInterface;
018  use OAuth\Common\Storage\TokenStorageInterface;
019  use OAuth\Common\Http\Uri\UriInterface;
020   
021  /**
022   * Vimeo service.
023   *
024   * @author  Pedro Amorim <contact@pamorim.fr>
025   * @license http://www.opensource.org/licenses/mit-license.html MIT License
026   * @link    https://developer.vimeo.com/
027   * @link    https://developer.vimeo.com/api/authentication
028   */
029  class Vimeo extends AbstractService
030  {
031      // API version
032      const VERSION = '3.2';
033      // API Header Accept
034      const HEADER_ACCEPT = 'application/vnd.vimeo.*+json;version=3.2';
035   
036      /**
037       * Scopes
038       * @see  https://developer.vimeo.com/api/authentication#scope
039       */
040      // View public videos
041      const SCOPE_PUBLIC    = 'public';
042      // View private videos
043      const SCOPE_PRIVATE   = 'private';
044      // View Vimeo On Demand purchase history
045      const SCOPE_PURCHASED = 'purchased';
046      // Create new videos, groups, albums, etc.
047      const SCOPE_CREATE    = 'create';
048      // Edit videos, groups, albums, etc.
049      const SCOPE_EDIT      = 'edit';
050      // Delete videos, groups, albums, etc.
051      const SCOPE_DELETE    = 'delete';
052      // Interact with a video on behalf of a user, such as liking
053      // a video or adding it to your watch later queue
054      const SCOPE_INTERACT  = 'interact';
055      // Upload a video
056      const SCOPE_UPLOAD    = 'upload';
057   
058      public function __construct(
059          CredentialsInterface $credentials,
060          ClientInterface $httpClient,
061          TokenStorageInterface $storage,
062          $scopes = array(),
063          UriInterface $baseApiUri = null
064      ) {
065          parent::__construct(
066              $credentials,
067              $httpClient,
068              $storage,
069              $scopes,
070              $baseApiUri,
071              true
072          );
073   
074          if (null === $baseApiUri) {
075              $this->baseApiUri = new Uri('https://api.vimeo.com/');
076          }
077      }
078   
079      /**
080       * {@inheritdoc}
081       */
082      public function getAuthorizationEndpoint()
083      {
084          return new Uri('https://api.vimeo.com/oauth/authorize');
085      }
086   
087      /**
088       * {@inheritdoc}
089       */
090      public function getAccessTokenEndpoint()
091      {
092          return new Uri('https://api.vimeo.com/oauth/access_token');
093      }
094   
095      /**
096       * {@inheritdoc}
097       */
098      protected function getAuthorizationMethod()
099      {
100          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
101      }
102   
103      /**
104       * {@inheritdoc}
105       */
106      protected function parseAccessTokenResponse($responseBody)
107      {
108          $data = json_decode($responseBody, true);
109   
110          if (null === $data || !is_array($data)) {
111              throw new TokenResponseException('Unable to parse response.');
112          } elseif (isset($data['error_description'])) {
113              throw new TokenResponseException(
114                  'Error in retrieving token: "' . $data['error_description'] . '"'
115              );
116          } elseif (isset($data['error'])) {
117              throw new TokenResponseException(
118                  'Error in retrieving token: "' . $data['error'] . '"'
119              );
120          }
121   
122          $token = new StdOAuth2Token();
123          $token->setAccessToken($data['access_token']);
124   
125          if (isset($data['expires_in'])) {
126              $token->setLifeTime($data['expires_in']);
127              unset($data['expires_in']);
128          }
129          if (isset($data['refresh_token'])) {
130              $token->setRefreshToken($data['refresh_token']);
131              unset($data['refresh_token']);
132          }
133   
134          unset($data['access_token']);
135   
136          $token->setExtraParams($data);
137   
138          return $token;
139      }
140   
141      /**
142       * {@inheritdoc}
143       */
144      protected function getExtraOAuthHeaders()
145      {
146          return array('Accept' => self::HEADER_ACCEPT);
147      }
148   
149      /**
150       * {@inheritdoc}
151       */
152      protected function getExtraApiHeaders()
153      {
154          return array('Accept' => self::HEADER_ACCEPT);
155      }
156  }
157