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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Yahoo.php
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 use OAuth\OAuth1\Token\TokenInterface;
014
015 class Yahoo extends AbstractService
016 {
017 public function __construct(
018 CredentialsInterface $credentials,
019 ClientInterface $httpClient,
020 TokenStorageInterface $storage,
021 SignatureInterface $signature,
022 UriInterface $baseApiUri = null
023 ) {
024 parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
025
026 if (null === $baseApiUri) {
027 $this->baseApiUri = new Uri('https://social.yahooapis.com/v1/');
028 }
029 }
030
031 /**
032 * {@inheritDoc}
033 */
034 public function getRequestTokenEndpoint()
035 {
036 return new Uri('https://api.login.yahoo.com/oauth/v2/get_request_token');
037 }
038
039 /**
040 * {@inheritdoc}
041 */
042 public function getAuthorizationEndpoint()
043 {
044 return new Uri('https://api.login.yahoo.com/oauth/v2/request_auth');
045 }
046
047 /**
048 * {@inheritdoc}
049 */
050 public function getAccessTokenEndpoint()
051 {
052 return new Uri('https://api.login.yahoo.com/oauth/v2/get_token');
053 }
054
055 /**
056 * {@inheritdoc}
057 */
058 public function refreshAccessToken(TokenInterface $token)
059 {
060 $extraParams = $token->getExtraParams();
061 $bodyParams = array('oauth_session_handle' => $extraParams['oauth_session_handle']);
062
063 $authorizationHeader = array(
064 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest(
065 'POST',
066 $this->getAccessTokenEndpoint(),
067 $this->storage->retrieveAccessToken($this->service()),
068 $bodyParams
069 )
070 );
071
072
073
074 $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders(), array());
075
076 $responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers);
077
078 $token = $this->parseAccessTokenResponse($responseBody);
079 $this->storage->storeAccessToken($this->service(), $token);
080
081 return $token;
082 }
083
084 /**
085 * {@inheritdoc}
086 */
087 protected function parseRequestTokenResponse($responseBody)
088 {
089 parse_str($responseBody, $data);
090
091 if (null === $data || !is_array($data)) {
092 throw new TokenResponseException('Unable to parse response.');
093 } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
094 throw new TokenResponseException('Error in retrieving token.');
095 }
096
097 return $this->parseAccessTokenResponse($responseBody);
098 }
099
100 /**
101 * {@inheritdoc}
102 */
103 protected function parseAccessTokenResponse($responseBody)
104 {
105 parse_str($responseBody, $data);
106
107 if (null === $data || !is_array($data)) {
108 throw new TokenResponseException('Unable to parse response.');
109 } elseif (isset($data['error'])) {
110 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
111 }
112
113 $token = new StdOAuth1Token();
114
115 $token->setRequestToken($data['oauth_token']);
116 $token->setRequestTokenSecret($data['oauth_token_secret']);
117 $token->setAccessToken($data['oauth_token']);
118 $token->setAccessTokenSecret($data['oauth_token_secret']);
119
120 if (isset($data['oauth_expires_in'])) {
121 $token->setLifetime($data['oauth_expires_in']);
122 } else {
123 $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
124 }
125
126 unset($data['oauth_token'], $data['oauth_token_secret']);
127 $token->setExtraParams($data);
128
129 return $token;
130 }
131 }
132