Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

Deezer.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.54 KiB


 001  <?php
 002  /**
 003   * Deezer service.
 004   *
 005   * @author  Pedro Amorim <contact@pamorim.fr>
 006   * @license http://www.opensource.org/licenses/mit-license.html MIT License
 007   *
 008   * @see    http://developers.deezer.com/api/
 009   */
 010   
 011  namespace OAuth\OAuth2\Service;
 012   
 013  use OAuth\Common\Consumer\CredentialsInterface;
 014  use OAuth\Common\Http\Client\ClientInterface;
 015  use OAuth\Common\Http\Exception\TokenResponseException;
 016  use OAuth\Common\Http\Uri\Uri;
 017  use OAuth\Common\Http\Uri\UriInterface;
 018  use OAuth\Common\Storage\TokenStorageInterface;
 019  use OAuth\OAuth2\Token\StdOAuth2Token;
 020   
 021  /**
 022   * Deezer service.
 023   *
 024   * @author  Pedro Amorim <contact@pamorim.fr>
 025   * @license http://www.opensource.org/licenses/mit-license.html MIT License
 026   *
 027   * @see    http://developers.deezer.com/api/
 028   */
 029  class Deezer extends AbstractService
 030  {
 031      /**
 032       * Defined scopes
 033       * http://developers.deezer.com/api/permissions.
 034       */
 035      const SCOPE_BASIC_ACCESS = 'basic_access';       // Access users basic information
 036      const SCOPE_EMAIL = 'email';              // Get the user's email
 037      const SCOPE_OFFLINE_ACCESS = 'offline_access';     // Access user data any time
 038      const SCOPE_MANAGE_LIBRARY = 'manage_library';     // Manage users' library
 039      const SCOPE_MANAGE_COMMUNITY = 'manage_community';   // Manage users' friends
 040      const SCOPE_DELETE_LIBRARY = 'delete_library';     // Delete library items
 041      const SCOPE_LISTENING_HISTORY = 'listening_history';  // Access the user's listening history
 042   
 043      public function __construct(
 044          CredentialsInterface $credentials,
 045          ClientInterface $httpClient,
 046          TokenStorageInterface $storage,
 047          $scopes = [],
 048          ?UriInterface $baseApiUri = null
 049      ) {
 050          parent::__construct(
 051              $credentials,
 052              $httpClient,
 053              $storage,
 054              $scopes,
 055              $baseApiUri,
 056              true
 057          );
 058   
 059          if (null === $baseApiUri) {
 060              $this->baseApiUri = new Uri('https://api.deezer.com/');
 061          }
 062      }
 063   
 064      /**
 065       * {@inheritdoc}
 066       */
 067      public function getAuthorizationEndpoint()
 068      {
 069          return new Uri('https://connect.deezer.com/oauth/auth.php');
 070      }
 071   
 072      /**
 073       * {@inheritdoc}
 074       */
 075      public function getAccessTokenEndpoint()
 076      {
 077          return new Uri('https://connect.deezer.com/oauth/access_token.php');
 078      }
 079   
 080      /**
 081       * {@inheritdoc}
 082       */
 083      protected function getAuthorizationMethod()
 084      {
 085          return static::AUTHORIZATION_METHOD_QUERY_STRING;
 086      }
 087   
 088      /**
 089       * {@inheritdoc}
 090       */
 091      protected function parseAccessTokenResponse($responseBody)
 092      {
 093          parse_str($responseBody, $data);
 094          if (null === $data || !is_array($data) || empty($data)) {
 095              throw new TokenResponseException('Unable to parse response.');
 096          } elseif (isset($data['error'])) {
 097              throw new TokenResponseException(
 098                  'Error in retrieving token: "' . $data['error'] . '"'
 099              );
 100          } elseif (isset($data['error_reason'])) {
 101              throw new TokenResponseException(
 102                  'Error in retrieving token: "' . $data['error_reason'] . '"'
 103              );
 104          }
 105   
 106          $token = new StdOAuth2Token();
 107          $token->setAccessToken($data['access_token']);
 108          $token->setLifeTime($data['expires']);
 109   
 110          // I hope one day Deezer add a refresh token :)
 111          if (isset($data['refresh_token'])) {
 112              $token->setRefreshToken($data['refresh_token']);
 113              unset($data['refresh_token']);
 114          }
 115   
 116          unset($data['access_token'], $data['expires']);
 117   
 118          $token->setExtraParams($data);
 119   
 120          return $token;
 121      }
 122  }
 123