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

Spotify.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.16 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  class Spotify extends AbstractService
 014  {
 015      /**
 016       * Scopes.
 017       *
 018       * @var string
 019       */
 020      const SCOPE_PLAYLIST_MODIFY_PUBLIC = 'playlist-modify-public';
 021      const SCOPE_PLAYLIST_MODIFY_PRIVATE = 'playlist-modify-private';
 022      const SCOPE_PLAYLIST_READ_PRIVATE = 'playlist-read-private';
 023      const SCOPE_PLAYLIST_READ_COLABORATIVE = 'playlist-read-collaborative';
 024      const SCOPE_STREAMING = 'streaming';
 025      const SCOPE_USER_LIBRARY_MODIFY = 'user-library-modify';
 026      const SCOPE_USER_LIBRARY_READ = 'user-library-read';
 027      const SCOPE_USER_READ_PRIVATE = 'user-read-private';
 028      const SCOPE_USER_READ_EMAIL = 'user-read-email';
 029      const SCOPE_USER_READ_BIRTHDAY = 'user-read-birthdate';
 030      const SCOPE_USER_READ_FOLLOW = 'user-follow-read';
 031   
 032      public function __construct(
 033          CredentialsInterface $credentials,
 034          ClientInterface $httpClient,
 035          TokenStorageInterface $storage,
 036          $scopes = [],
 037          ?UriInterface $baseApiUri = null
 038      ) {
 039          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
 040   
 041          if (null === $baseApiUri) {
 042              $this->baseApiUri = new Uri('https://api.spotify.com/v1/');
 043          }
 044      }
 045   
 046      /**
 047       * {@inheritdoc}
 048       */
 049      public function getAuthorizationEndpoint()
 050      {
 051          return new Uri('https://accounts.spotify.com/authorize');
 052      }
 053   
 054      /**
 055       * {@inheritdoc}
 056       */
 057      public function getAccessTokenEndpoint()
 058      {
 059          return new Uri('https://accounts.spotify.com/api/token');
 060      }
 061   
 062      /**
 063       * {@inheritdoc}
 064       */
 065      protected function getAuthorizationMethod()
 066      {
 067          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
 068      }
 069   
 070      /**
 071       * {@inheritdoc}
 072       */
 073      protected function parseAccessTokenResponse($responseBody)
 074      {
 075          $data = json_decode($responseBody, true);
 076   
 077          if (null === $data || !is_array($data)) {
 078              throw new TokenResponseException('Unable to parse response.');
 079          } elseif (isset($data['error'])) {
 080              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 081          }
 082   
 083          $token = new StdOAuth2Token();
 084          $token->setAccessToken($data['access_token']);
 085   
 086          if (isset($data['expires_in'])) {
 087              $token->setLifetime($data['expires_in']);
 088              unset($data['expires_in']);
 089          }
 090   
 091          if (isset($data['refresh_token'])) {
 092              $token->setRefreshToken($data['refresh_token']);
 093              unset($data['refresh_token']);
 094          }
 095   
 096          unset($data['access_token']);
 097   
 098          $token->setExtraParams($data);
 099   
 100          return $token;
 101      }
 102   
 103      /**
 104       * {@inheritdoc}
 105       */
 106      protected function getExtraOAuthHeaders()
 107      {
 108          return ['Authorization' => 'Basic ' .
 109              base64_encode($this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret()), ];
 110      }
 111  }
 112