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

BattleNet.php

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


 001  <?php
 002   
 003  namespace OAuth\OAuth2\Service;
 004   
 005  //-----------------------------------------------------------------------------
 006  use OAuth\Common\Consumer\CredentialsInterface;
 007  use OAuth\Common\Http\Client\ClientInterface;
 008  use OAuth\Common\Http\Exception\TokenResponseException;
 009  use OAuth\Common\Http\Uri\Uri;
 010  use OAuth\Common\Http\Uri\UriInterface;
 011  use OAuth\Common\Storage\TokenStorageInterface;
 012  use OAuth\OAuth2\Token\StdOAuth2Token;
 013   
 014  //-----------------------------------------------------------------------------
 015  class BattleNet extends AbstractService
 016  {
 017      /** -----------------------------------------------------------------------
 018       * Defined scopes.
 019       *
 020       * @see https://dev.battle.net/docs
 021       */
 022      const SCOPE_WOW_PROFILE = 'wow.profile';
 023      const SCOPE_SC2_PROFILE = 'sc2.profile';
 024   
 025      /** -----------------------------------------------------------------------
 026       * Defined API URIs.
 027       *
 028       * @see https://dev.battle.net/docs
 029       */
 030      const API_URI_US = 'https://us.api.battle.net/';
 031      const API_URI_EU = 'https://eu.api.battle.net/';
 032      const API_URI_KR = 'https://kr.api.battle.net/';
 033      const API_URI_TW = 'https://tw.api.battle.net/';
 034      const API_URI_CN = 'https://api.battlenet.com.cn/';
 035      const API_URI_SEA = 'https://sea.api.battle.net/';
 036   
 037      public function __construct(CredentialsInterface $credentials,
 038                                   ClientInterface $httpClient,
 039                                   TokenStorageInterface $storage,
 040                                   $scopes = [],
 041                                   ?UriInterface $baseApiUri = null)
 042      {
 043          parent::__construct($credentials, $httpClient, $storage,
 044                               $scopes, $baseApiUri);
 045   
 046          if ($baseApiUri === null) {
 047              $this->baseApiUri = new Uri(self::API_URI_US);
 048          }
 049      }
 050   
 051      /** -----------------------------------------------------------------------
 052       * Translates the current base API URI into an OAuth base URI.
 053       *
 054       * @returns string Base URI of oauth services.
 055       */
 056      private function GetOAuthBaseUri()
 057      {
 058   
 059          // i love china
 060          switch ($this->baseApiUri) {
 061              case self::API_URI_US:  return 'https://us.battle.net/oauth/';
 062              case self::API_URI_EU:  return 'https://eu.battle.net/oauth/';
 063              case self::API_URI_KR:  return 'https://kr.battle.net/oauth/';
 064              case self::API_URI_TW:  return 'https://tw.battle.net/oauth/';
 065              case self::API_URI_CN:  return 'https://www.battlenet.com.cn/oauth/';
 066              case self::API_URI_SEA: return 'https://sea.battle.net/oauth/';
 067          }
 068      }
 069   
 070      /** -----------------------------------------------------------------------
 071       * {@inheritdoc}
 072       */
 073      public function getAuthorizationEndpoint()
 074      {
 075          return new Uri($this->GetOAuthBaseUri() . 'authorize');
 076      }
 077   
 078      /** -----------------------------------------------------------------------
 079       * {@inheritdoc}
 080       */
 081      public function getAccessTokenEndpoint()
 082      {
 083          return new Uri($this->GetOAuthBaseUri() . 'token');
 084      }
 085   
 086      /** -----------------------------------------------------------------------
 087       * {@inheritdoc}
 088       */
 089      protected function getAuthorizationMethod()
 090      {
 091          return static::AUTHORIZATION_METHOD_QUERY_STRING;
 092      }
 093   
 094      /** -----------------------------------------------------------------------
 095       * {@inheritdoc}
 096       */
 097      protected function parseAccessTokenResponse($responseBody)
 098      {
 099          $data = json_decode($responseBody, true);
 100          if ($data === null || !is_array($data)) {
 101              throw new TokenResponseException('Unable to parse response.');
 102          } elseif (isset($data['error'])) {
 103              $err = $data['error'];
 104   
 105              throw new TokenResponseException(
 106                                  "Error in retrieving token: \"$err\"");
 107          }
 108   
 109          $token = new StdOAuth2Token($data['access_token'], null,
 110                                       $data['expires_in']);
 111   
 112          unset($data['access_token'] , $data['expires_in']);
 113   
 114          $token->setExtraParams($data);
 115   
 116          return $token;
 117      }
 118  }
 119