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

Twitter.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.49 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 Twitter 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://api.twitter.com/1.1/');
 20          }
 21      }
 22   
 23      /**
 24       * @return \OAuth\Common\Http\Uri\UriInterface
 25       */
 26      public function getRequestTokenEndpoint()
 27      {
 28          return new Uri('https://api.twitter.com/oauth/request_token');
 29      }
 30   
 31      /**
 32       * @return \OAuth\Common\Http\Uri\UriInterface
 33       */
 34      public function getAuthorizationEndpoint()
 35      {
 36          // @todo if the app will post tweets, authorize must be used instead.
 37          // figure something out re: that but it's late and i don't want to now
 38          return new Uri('https://api.twitter.com/oauth/authenticate');
 39      }
 40   
 41      /**
 42       * @return \OAuth\Common\Http\Uri\UriInterface
 43       */
 44      public function getAccessTokenEndpoint()
 45      {
 46          return new Uri('https://api.twitter.com/oauth/access_token');
 47      }
 48   
 49      /**
 50       * We need a separate request token parser only to verify the `oauth_callback_confirmed` parameter. For the actual
 51       * parsing we can just use the default access token parser.
 52       *
 53       * @param string $responseBody
 54       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth1\Token\StdOAuth1Token
 55       * @throws \OAuth\Common\Http\Exception\TokenResponseException
 56       */
 57      protected function parseRequestTokenResponse($responseBody)
 58      {
 59          parse_str($responseBody, $data);
 60   
 61          if( null === $data || !is_array($data) ) {
 62              throw new TokenResponseException('Unable to parse response.');
 63          } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {
 64              throw new TokenResponseException('Error in retrieving token.');
 65          }
 66   
 67          return $this->parseAccessTokenResponse($responseBody);
 68      }
 69   
 70      /**
 71       * @param string $responseBody
 72       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth1\Token\StdOAuth1Token
 73       * @throws \OAuth\Common\Http\Exception\TokenResponseException
 74       */
 75      protected function parseAccessTokenResponse($responseBody)
 76      {
 77          parse_str($responseBody, $data);
 78   
 79          if( null === $data || !is_array($data) ) {
 80              throw new TokenResponseException('Unable to parse response.');
 81          } elseif( isset($data['error'] ) ) {
 82              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 83          }
 84   
 85          $token = new StdOAuth1Token();
 86   
 87          $token->setRequestToken( $data['oauth_token'] );
 88          $token->setRequestTokenSecret( $data['oauth_token_secret'] );
 89          $token->setAccessToken( $data['oauth_token'] );
 90          $token->setAccessTokenSecret( $data['oauth_token_secret'] );
 91   
 92          $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
 93          unset( $data['oauth_token'], $data['oauth_token_secret'] );
 94          $token->setExtraParams( $data );
 95   
 96          return $token;
 97      }
 98  }
 99