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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
QuickBooks.php
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
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
092 throw new TokenResponseException($message);
093 }
094
095 $token = new StdOAuth1Token();
096
097 $token->setRequestToken($data['oauth_token']);
098 $token->setRequestTokenSecret($data['oauth_token_secret']);
099 $token->setAccessToken($data['oauth_token']);
100 $token->setAccessTokenSecret($data['oauth_token_secret']);
101
102 $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
103 unset($data['oauth_token'], $data['oauth_token_secret']);
104 $token->setExtraParams($data);
105
106 return $token;
107 }
108
109 /**
110 * {@inheritdoc}
111 */
112 public function request(
113 $path,
114 $method = 'GET',
115 $body = null,
116 array $extraHeaders = []
117 ) {
118 $extraHeaders['Accept'] = 'application/json';
119
120 return parent::request($path, $method, $body, $extraHeaders);
121 }
122 }
123