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 |
Flickr.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 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
055 return $this->parseAccessTokenResponse($responseBody);
056 }
057
058 protected function parseAccessTokenResponse($responseBody)
059 {
060 parse_str($responseBody, $data);
061 if ($data === null || !is_array($data)) {
062 throw new TokenResponseException('Unable to parse response.');
063 } elseif (isset($data['error'])) {
064 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
065 }
066
067 $token = new StdOAuth1Token();
068 $token->setRequestToken($data['oauth_token']);
069 $token->setRequestTokenSecret($data['oauth_token_secret']);
070 $token->setAccessToken($data['oauth_token']);
071 $token->setAccessTokenSecret($data['oauth_token_secret']);
072 $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
073 unset($data['oauth_token'], $data['oauth_token_secret']);
074 $token->setExtraParams($data);
075
076 return $token;
077 }
078
079 public function request($path, $method = 'GET', $body = null, array $extraHeaders = [])
080 {
081 $uri = $this->determineRequestUriFromPath('/', $this->baseApiUri);
082 $uri->addToQuery('method', $path);
083
084 if (!empty($this->format)) {
085 $uri->addToQuery('format', $this->format);
086
087 if ($this->format === 'json') {
088 $uri->addToQuery('nojsoncallback', 1);
089 }
090 }
091
092 $token = $this->storage->retrieveAccessToken($this->service());
093 $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);
094 $authorizationHeader = [
095 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body),
096 ];
097 $headers = array_merge($authorizationHeader, $extraHeaders);
098
099 return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);
100 }
101
102 public function requestRest($path, $method = 'GET', $body = null, array $extraHeaders = [])
103 {
104 return $this->request($path, $method, $body, $extraHeaders);
105 }
106
107 public function requestXmlrpc($path, $method = 'GET', $body = null, array $extraHeaders = [])
108 {
109 $this->format = 'xmlrpc';
110
111 return $this->request($path, $method, $body, $extraHeaders);
112 }
113
114 public function requestSoap($path, $method = 'GET', $body = null, array $extraHeaders = [])
115 {
116 $this->format = 'soap';
117
118 return $this->request($path, $method, $body, $extraHeaders);
119 }
120
121 public function requestJson($path, $method = 'GET', $body = null, array $extraHeaders = [])
122 {
123 $this->format = 'json';
124
125 return $this->request($path, $method, $body, $extraHeaders);
126 }
127
128 public function requestPhp($path, $method = 'GET', $body = null, array $extraHeaders = [])
129 {
130 $this->format = 'php_serial';
131
132 return $this->request($path, $method, $body, $extraHeaders);
133 }
134 }
135