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 |
Dropbox.php
001 <?php
002
003 namespace OAuth\OAuth2\Service;
004
005 use OAuth\OAuth2\Token\StdOAuth2Token;
006 use OAuth\Common\Http\Exception\TokenResponseException;
007 use OAuth\Common\Http\Uri\Uri;
008 use OAuth\Common\Consumer\CredentialsInterface;
009 use OAuth\Common\Http\Client\ClientInterface;
010 use OAuth\Common\Storage\TokenStorageInterface;
011 use OAuth\Common\Http\Uri\UriInterface;
012
013 /**
014 * Dropbox service.
015 *
016 * @author Flávio Heleno <flaviohbatista@gmail.com>
017 * @link https://www.dropbox.com/developers/core/docs
018 */
019 class Dropbox extends AbstractService
020 {
021 public function __construct(
022 CredentialsInterface $credentials,
023 ClientInterface $httpClient,
024 TokenStorageInterface $storage,
025 $scopes = array(),
026 UriInterface $baseApiUri = null
027 ) {
028 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
029
030 if (null === $baseApiUri) {
031 $this->baseApiUri = new Uri('https://api.dropbox.com/1/');
032 }
033 }
034
035 /**
036 * {@inheritdoc}
037 */
038 public function getAuthorizationUri(array $additionalParameters = array())
039 {
040 $parameters = array_merge(
041 $additionalParameters,
042 array(
043 'client_id' => $this->credentials->getConsumerId(),
044 'redirect_uri' => $this->credentials->getCallbackUrl(),
045 'response_type' => 'code',
046 )
047 );
048
049 $parameters['scope'] = implode(' ', $this->scopes);
050
051 // Build the url
052 $url = clone $this->getAuthorizationEndpoint();
053 foreach ($parameters as $key => $val) {
054 $url->addToQuery($key, $val);
055 }
056
057 return $url;
058 }
059
060 /**
061 * {@inheritdoc}
062 */
063 public function getAuthorizationEndpoint()
064 {
065 return new Uri('https://www.dropbox.com/1/oauth2/authorize');
066 }
067
068 /**
069 * {@inheritdoc}
070 */
071 public function getAccessTokenEndpoint()
072 {
073 return new Uri('https://api.dropbox.com/1/oauth2/token');
074 }
075
076 /**
077 * {@inheritdoc}
078 */
079 protected function getAuthorizationMethod()
080 {
081 return static::AUTHORIZATION_METHOD_QUERY_STRING;
082 }
083
084 /**
085 * {@inheritdoc}
086 */
087 protected function parseAccessTokenResponse($responseBody)
088 {
089 $data = json_decode($responseBody, true);
090
091 if (null === $data || !is_array($data)) {
092 throw new TokenResponseException('Unable to parse response.');
093 } elseif (isset($data['error'])) {
094 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
095 }
096
097 $token = new StdOAuth2Token();
098 $token->setAccessToken($data['access_token']);
099
100 if (isset($data['refresh_token'])) {
101 $token->setRefreshToken($data['refresh_token']);
102 unset($data['refresh_token']);
103 }
104
105 unset($data['access_token']);
106
107 $token->setExtraParams($data);
108
109 return $token;
110 }
111 }
112