Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

Dailymotion.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 3.27 KiB


001  <?php
002   
003  namespace OAuth\OAuth2\Service;
004   
005  use OAuth\Common\Consumer\CredentialsInterface;
006  use OAuth\Common\Http\Client\ClientInterface;
007  use OAuth\Common\Http\Exception\TokenResponseException;
008  use OAuth\Common\Http\Uri\Uri;
009  use OAuth\Common\Http\Uri\UriInterface;
010  use OAuth\Common\Storage\TokenStorageInterface;
011  use OAuth\OAuth2\Token\StdOAuth2Token;
012   
013  /**
014   * Dailymotion service.
015   *
016   * @author Mouhamed SEYE <mouhamed@seye.pro>
017   *
018   * @see http://www.dailymotion.com/doc/api/authentication.html
019   */
020  class Dailymotion extends AbstractService
021  {
022      /**
023       * Scopes.
024       *
025       * @var string
026       */
027      const SCOPE_EMAIL = 'email';
028      const SCOPE_PROFILE = 'userinfo';
029      const SCOPE_VIDEOS = 'manage_videos';
030      const SCOPE_COMMENTS = 'manage_comments';
031      const SCOPE_PLAYLIST = 'manage_playlists';
032      const SCOPE_TILES = 'manage_tiles';
033      const SCOPE_SUBSCRIPTIONS = 'manage_subscriptions';
034      const SCOPE_FRIENDS = 'manage_friends';
035      const SCOPE_FAVORITES = 'manage_favorites';
036      const SCOPE_GROUPS = 'manage_groups';
037   
038      /**
039       * Dialog form factors.
040       *
041       * @var string
042       */
043      const DISPLAY_PAGE = 'page';
044      const DISPLAY_POPUP = 'popup';
045      const DISPLAY_MOBILE = 'mobile';
046   
047      /**
048       * {@inheritdoc}
049       */
050      public function __construct(
051          CredentialsInterface $credentials,
052          ClientInterface $httpClient,
053          TokenStorageInterface $storage,
054          $scopes = [],
055          ?UriInterface $baseApiUri = null
056      ) {
057          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
058   
059          if (null === $baseApiUri) {
060              $this->baseApiUri = new Uri('https://api.dailymotion.com/');
061          }
062      }
063   
064      /**
065       * {@inheritdoc}
066       */
067      public function getAuthorizationEndpoint()
068      {
069          return new Uri('https://api.dailymotion.com/oauth/authorize');
070      }
071   
072      /**
073       * {@inheritdoc}
074       */
075      public function getAccessTokenEndpoint()
076      {
077          return new Uri('https://api.dailymotion.com/oauth/token');
078      }
079   
080      /**
081       * {@inheritdoc}
082       */
083      protected function getAuthorizationMethod()
084      {
085          return static::AUTHORIZATION_METHOD_HEADER_OAUTH;
086      }
087   
088      /**
089       * {@inheritdoc}
090       */
091      protected function parseAccessTokenResponse($responseBody)
092      {
093          $data = json_decode($responseBody, true);
094   
095          if (null === $data || !is_array($data)) {
096              throw new TokenResponseException('Unable to parse response.');
097          } elseif (isset($data['error_description']) || isset($data['error'])) {
098              throw new TokenResponseException(
099                  sprintf(
100                      'Error in retrieving token: "%s"',
101                      $data['error_description'] ?? $data['error']
102                  )
103              );
104          }
105   
106          $token = new StdOAuth2Token();
107          $token->setAccessToken($data['access_token']);
108          $token->setLifeTime($data['expires_in']);
109   
110          if (isset($data['refresh_token'])) {
111              $token->setRefreshToken($data['refresh_token']);
112              unset($data['refresh_token']);
113          }
114   
115          unset($data['access_token'], $data['expires_in']);
116   
117          $token->setExtraParams($data);
118   
119          return $token;
120      }
121   
122      /**
123       * {@inheritdoc}
124       */
125      protected function getExtraOAuthHeaders()
126      {
127          return ['Accept' => 'application/json'];
128      }
129  }
130