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

Flickr.php

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


001  <?php
002   
003  namespace OAuth\OAuth1\Service;
004   
005  use OAuth\OAuth1\Signature\SignatureInterface;
006  use OAuth\OAuth1\Token\StdOAuth1Token;
007  use OAuth\Common\Http\Exception\TokenResponseException;
008  use OAuth\Common\Http\Uri\Uri;
009  use OAuth\Common\Consumer\CredentialsInterface;
010  use OAuth\Common\Http\Uri\UriInterface;
011  use OAuth\Common\Storage\TokenStorageInterface;
012  use OAuth\Common\Http\Client\ClientInterface;
013   
014  class Flickr extends AbstractService
015  {
016      protected $format;
017   
018      public function __construct(
019          CredentialsInterface $credentials,
020          ClientInterface $httpClient,
021          TokenStorageInterface $storage,
022          SignatureInterface $signature,
023          UriInterface $baseApiUri = null
024      ) {
025          parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
026          if ($baseApiUri === null) {
027              $this->baseApiUri = new Uri('https://api.flickr.com/services/rest/');
028          }
029      }
030   
031      public function getRequestTokenEndpoint()
032      {
033          return new Uri('https://www.flickr.com/services/oauth/request_token');
034      }
035   
036      public function getAuthorizationEndpoint()
037      {
038          return new Uri('https://www.flickr.com/services/oauth/authorize');
039      }
040   
041      public function getAccessTokenEndpoint()
042      {
043          return new Uri('https://www.flickr.com/services/oauth/access_token');
044      }
045   
046      protected function parseRequestTokenResponse($responseBody)
047      {
048          parse_str($responseBody, $data);
049          if (null === $data || !is_array($data)) {
050              throw new TokenResponseException('Unable to parse response.');
051          } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {
052              throw new TokenResponseException('Error in retrieving token.');
053          }
054          return $this->parseAccessTokenResponse($responseBody);
055      }
056   
057      protected function parseAccessTokenResponse($responseBody)
058      {
059          parse_str($responseBody, $data);
060          if ($data === null || !is_array($data)) {
061              throw new TokenResponseException('Unable to parse response.');
062          } elseif (isset($data['error'])) {
063              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
064          }
065   
066          $token = new StdOAuth1Token();
067          $token->setRequestToken($data['oauth_token']);
068          $token->setRequestTokenSecret($data['oauth_token_secret']);
069          $token->setAccessToken($data['oauth_token']);
070          $token->setAccessTokenSecret($data['oauth_token_secret']);
071          $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
072          unset($data['oauth_token'], $data['oauth_token_secret']);
073          $token->setExtraParams($data);
074   
075          return $token;
076      }
077   
078      public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
079      {
080          $uri = $this->determineRequestUriFromPath('/', $this->baseApiUri);
081          $uri->addToQuery('method', $path);
082   
083          if (!empty($this->format)) {
084              $uri->addToQuery('format', $this->format);
085   
086              if ($this->format === 'json') {
087                  $uri->addToQuery('nojsoncallback', 1);
088              }
089          }
090   
091          $token = $this->storage->retrieveAccessToken($this->service());
092          $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);
093          $authorizationHeader = array(
094              'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body)
095          );
096          $headers = array_merge($authorizationHeader, $extraHeaders);
097   
098          return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);
099      }
100   
101      public function requestRest($path, $method = 'GET', $body = null, array $extraHeaders = array())
102      {
103          return $this->request($path, $method, $body, $extraHeaders);
104      }
105   
106      public function requestXmlrpc($path, $method = 'GET', $body = null, array $extraHeaders = array())
107      {
108          $this->format = 'xmlrpc';
109   
110          return $this->request($path, $method, $body, $extraHeaders);
111      }
112   
113      public function requestSoap($path, $method = 'GET', $body = null, array $extraHeaders = array())
114      {
115          $this->format = 'soap';
116   
117          return $this->request($path, $method, $body, $extraHeaders);
118      }
119   
120      public function requestJson($path, $method = 'GET', $body = null, array $extraHeaders = array())
121      {
122          $this->format = 'json';
123   
124          return $this->request($path, $method, $body, $extraHeaders);
125      }
126   
127      public function requestPhp($path, $method = 'GET', $body = null, array $extraHeaders = array())
128      {
129          $this->format = 'php_serial';
130   
131          return $this->request($path, $method, $body, $extraHeaders);
132      }
133  }
134