Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

BitBucket.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.36 KiB


01  <?php
02  namespace OAuth\OAuth1\Service;
03   
04  use OAuth\OAuth1\Signature\SignatureInterface;
05  use OAuth\OAuth1\Token\StdOAuth1Token;
06  use OAuth\Common\Http\Exception\TokenResponseException;
07  use OAuth\Common\Http\Uri\Uri;
08  use OAuth\Common\Consumer\Credentials;
09  use OAuth\Common\Http\Uri\UriInterface;
10  use OAuth\Common\Storage\TokenStorageInterface;
11  use OAuth\Common\Http\Client\ClientInterface;
12   
13  class BitBucket extends AbstractService
14  {
15      public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, SignatureInterface $signature, UriInterface $baseApiUri = null)
16      {
17          parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
18          if( null === $baseApiUri ) {
19              $this->baseApiUri = new Uri('https://bitbucket.org/api/1.0/');
20          }
21      }
22   
23      /**
24       * @return \OAuth\Common\Http\Uri\UriInterface
25       */
26      public function getRequestTokenEndpoint()
27      {
28          return new Uri('https://bitbucket.org/!api/1.0/oauth/request_token');
29      }
30   
31      /**
32       * @return \OAuth\Common\Http\Uri\UriInterface
33       */
34      public function getAuthorizationEndpoint()
35      {
36          return new Uri('https://bitbucket.org/!api/1.0/oauth/authenticate');
37      }
38   
39      /**
40       * @return \OAuth\Common\Http\Uri\UriInterface
41       */
42      public function getAccessTokenEndpoint()
43      {
44          return new Uri('https://bitbucket.org/!api/1.0/oauth/access_token');
45      }
46   
47      /**
48       * We need a separate request token parser only to verify the `oauth_callback_confirmed` parameter. For the actual
49       * parsing we can just use the default access token parser.
50       *
51       * @param string $responseBody
52       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth1\Token\StdOAuth1Token
53       * @throws \OAuth\Common\Http\Exception\TokenResponseException
54       */
55      protected function parseRequestTokenResponse($responseBody)
56      {
57          parse_str($responseBody, $data);
58   
59          if( null === $data || !is_array($data) ) {
60              throw new TokenResponseException('Unable to parse response.');
61          } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {
62              throw new TokenResponseException('Error in retrieving token.');
63          }
64   
65          return $this->parseAccessTokenResponse($responseBody);
66      }
67   
68      /**
69       * @param string $responseBody
70       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth1\Token\StdOAuth1Token
71       * @throws \OAuth\Common\Http\Exception\TokenResponseException
72       */
73      protected function parseAccessTokenResponse($responseBody)
74      {
75   
76          parse_str($responseBody, $data);
77   
78          if( null === $data || !is_array($data) ) {
79              throw new TokenResponseException('Unable to parse response.');
80          } elseif( isset($data['error'] ) ) {
81              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
82          }
83   
84          $token = new StdOAuth1Token();
85   
86          $token->setRequestToken( $data['oauth_token'] );
87          $token->setRequestTokenSecret( $data['oauth_token_secret'] );
88          $token->setAccessToken( $data['oauth_token'] );
89          $token->setAccessTokenSecret( $data['oauth_token_secret'] );
90   
91          $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
92          unset( $data['oauth_token'], $data['oauth_token_secret'] );
93          $token->setExtraParams( $data );
94   
95          return $token;
96      }
97  }
98