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

Yahoo.php

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


001  <?php
002   
003  namespace OAuth\OAuth1\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\OAuth1\Signature\SignatureInterface;
012  use OAuth\OAuth1\Token\StdOAuth1Token;
013  use OAuth\OAuth1\Token\TokenInterface;
014   
015  class Yahoo extends AbstractService
016  {
017      public function __construct(
018          CredentialsInterface $credentials,
019          ClientInterface $httpClient,
020          TokenStorageInterface $storage,
021          SignatureInterface $signature,
022          ?UriInterface $baseApiUri = null
023      ) {
024          parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
025   
026          if (null === $baseApiUri) {
027              $this->baseApiUri = new Uri('https://social.yahooapis.com/v1/');
028          }
029      }
030   
031      /**
032       * {@inheritdoc}
033       */
034      public function getRequestTokenEndpoint()
035      {
036          return new Uri('https://api.login.yahoo.com/oauth/v2/get_request_token');
037      }
038   
039      /**
040       * {@inheritdoc}
041       */
042      public function getAuthorizationEndpoint()
043      {
044          return new Uri('https://api.login.yahoo.com/oauth/v2/request_auth');
045      }
046   
047      /**
048       * {@inheritdoc}
049       */
050      public function getAccessTokenEndpoint()
051      {
052          return new Uri('https://api.login.yahoo.com/oauth/v2/get_token');
053      }
054   
055      /**
056       * {@inheritdoc}
057       */
058      public function refreshAccessToken(TokenInterface $token)
059      {
060          $extraParams = $token->getExtraParams();
061          $bodyParams = ['oauth_session_handle' => $extraParams['oauth_session_handle']];
062   
063          $authorizationHeader = [
064              'Authorization' => $this->buildAuthorizationHeaderForAPIRequest(
065                  'POST',
066                  $this->getAccessTokenEndpoint(),
067                  $this->storage->retrieveAccessToken($this->service()),
068                  $bodyParams
069              ),
070          ];
071   
072          $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders(), []);
073   
074          $responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers);
075   
076          $token = $this->parseAccessTokenResponse($responseBody);
077          $this->storage->storeAccessToken($this->service(), $token);
078   
079          return $token;
080      }
081   
082      /**
083       * {@inheritdoc}
084       */
085      protected function parseRequestTokenResponse($responseBody)
086      {
087          parse_str($responseBody, $data);
088   
089          if (null === $data || !is_array($data)) {
090              throw new TokenResponseException('Unable to parse response.');
091          } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
092              throw new TokenResponseException('Error in retrieving token.');
093          }
094   
095          return $this->parseAccessTokenResponse($responseBody);
096      }
097   
098      /**
099       * {@inheritdoc}
100       */
101      protected function parseAccessTokenResponse($responseBody)
102      {
103          parse_str($responseBody, $data);
104   
105          if (null === $data || !is_array($data)) {
106              throw new TokenResponseException('Unable to parse response.');
107          } elseif (isset($data['error'])) {
108              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
109          }
110   
111          $token = new StdOAuth1Token();
112   
113          $token->setRequestToken($data['oauth_token']);
114          $token->setRequestTokenSecret($data['oauth_token_secret']);
115          $token->setAccessToken($data['oauth_token']);
116          $token->setAccessTokenSecret($data['oauth_token_secret']);
117   
118          if (isset($data['oauth_expires_in'])) {
119              $token->setLifetime($data['oauth_expires_in']);
120          } else {
121              $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
122          }
123   
124          unset($data['oauth_token'], $data['oauth_token_secret']);
125          $token->setExtraParams($data);
126   
127          return $token;
128      }
129  }
130