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

Dailymotion.php

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