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

QuickBooks.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 3.25 KiB


001  <?php
002   
003  namespace OAuth\OAuth1\Service;
004   
005  use OAuth\OAuth1\Token\StdOAuth1Token;
006  use OAuth\Common\Http\Exception\TokenResponseException;
007  use OAuth\Common\Http\Uri\Uri;
008  use OAuth\Common\Consumer\CredentialsInterface;
009  use OAuth\Common\Storage\TokenStorageInterface;
010  use OAuth\Common\Http\Client\ClientInterface;
011  use OAuth\Common\Http\Uri\UriInterface;
012  use OAuth\OAuth1\Signature\SignatureInterface;
013   
014  class QuickBooks extends AbstractService
015  {
016      /**
017       * {@inheritdoc}
018       */
019      public function __construct(
020          CredentialsInterface $credentials,
021          ClientInterface $httpClient,
022          TokenStorageInterface $storage,
023          SignatureInterface $signature,
024          UriInterface $baseApiUri = null
025      ) {
026          parent::__construct(
027              $credentials,
028              $httpClient,
029              $storage,
030              $signature,
031              $baseApiUri
032          );
033   
034          if (null === $baseApiUri) {
035              $this->baseApiUri = new Uri('https://quickbooks.api.intuit.com/');
036          }
037      }
038   
039      /**
040       * {@inheritdoc}
041       */
042      public function getRequestTokenEndpoint()
043      {
044          return new Uri('https://oauth.intuit.com/oauth/v1/get_request_token');
045      }
046   
047      /**
048       * {@inheritdoc}
049       */
050      public function getAuthorizationEndpoint()
051      {
052          return new Uri('https://appcenter.intuit.com/Connect/Begin');
053      }
054   
055      /**
056       * {@inheritdoc}
057       */
058      public function getAccessTokenEndpoint()
059      {
060          return new Uri('https://oauth.intuit.com/oauth/v1/get_access_token');
061      }
062   
063      /**
064       * {@inheritdoc}
065       */
066      protected function parseRequestTokenResponse($responseBody)
067      {
068          parse_str($responseBody, $data);
069   
070          if (null === $data || !is_array($data)) {
071              throw new TokenResponseException('Unable to parse response.');
072          } elseif (!isset($data['oauth_callback_confirmed'])
073              || $data['oauth_callback_confirmed'] !== 'true') {
074              throw new TokenResponseException('Error in retrieving token.');
075          }
076   
077          return $this->parseAccessTokenResponse($responseBody);
078      }
079   
080      /**
081       * {@inheritdoc}
082       */
083      protected function parseAccessTokenResponse($responseBody)
084      {
085          parse_str($responseBody, $data);
086   
087          if (null === $data || !is_array($data)) {
088              throw new TokenResponseException('Unable to parse response.');
089          } elseif (isset($data['error'])) {
090              $message = 'Error in retrieving token: "' . $data['error'] . '"';
091              throw new TokenResponseException($message);
092          }
093   
094          $token = new StdOAuth1Token();
095   
096          $token->setRequestToken($data['oauth_token']);
097          $token->setRequestTokenSecret($data['oauth_token_secret']);
098          $token->setAccessToken($data['oauth_token']);
099          $token->setAccessTokenSecret($data['oauth_token_secret']);
100   
101          $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
102          unset($data['oauth_token'], $data['oauth_token_secret']);
103          $token->setExtraParams($data);
104   
105          return $token;
106      }
107   
108      /**
109       * {@inheritDoc}
110       */
111      public function request(
112          $path,
113          $method = 'GET',
114          $body = null,
115          array $extraHeaders = array()
116      ) {
117          $extraHeaders['Accept'] = 'application/json';
118          return parent::request($path, $method, $body, $extraHeaders);
119      }
120  }
121