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 |
DeviantArt.php
001 <?php
002
003 namespace OAuth\OAuth2\Service;
004
005 use OAuth\Common\Exception\Exception;
006 use OAuth\OAuth2\Token\StdOAuth2Token;
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\Client\ClientInterface;
011 use OAuth\Common\Storage\TokenStorageInterface;
012 use OAuth\Common\Http\Uri\UriInterface;
013
014 class DeviantArt extends AbstractService
015 {
016 /**
017 * DeviantArt www url - used to build dialog urls
018 */
019 const WWW_URL = 'https://www.deviantart.com/';
020
021 /**
022 * Defined scopes
023 *
024 * If you don't think this is scary you should not be allowed on the web at all
025 *
026 * @link https://www.deviantart.com/developers/authentication
027 * @link https://www.deviantart.com/developers/http/v1/20150217
028 */
029 const SCOPE_FEED = 'feed';
030 const SCOPE_BROWSE = 'browse';
031 const SCOPE_COMMENT = 'comment.post';
032 const SCOPE_STASH = 'stash';
033 const SCOPE_USER = 'user';
034 const SCOPE_USERMANAGE = 'user.manage';
035
036 public function __construct(
037 CredentialsInterface $credentials,
038 ClientInterface $httpClient,
039 TokenStorageInterface $storage,
040 $scopes = array(),
041 UriInterface $baseApiUri = null
042 ) {
043 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
044
045 if (null === $baseApiUri) {
046 $this->baseApiUri = new Uri('https://www.deviantart.com/api/v1/oauth2/');
047 }
048 }
049
050 /**
051 * {@inheritdoc}
052 */
053 public function getAuthorizationEndpoint()
054 {
055 return new Uri('https://www.deviantart.com/oauth2/authorize');
056 }
057
058 /**
059 * {@inheritdoc}
060 */
061 public function getAccessTokenEndpoint()
062 {
063 return new Uri('https://www.deviantart.com/oauth2/token');
064 }
065
066 /**
067 * {@inheritdoc}
068 */
069 protected function parseAccessTokenResponse($responseBody)
070 {
071
072 $data = json_decode($responseBody, true);
073
074 if (null === $data || !is_array($data)) {
075 throw new TokenResponseException('Unable to parse response.');
076 } elseif (isset($data['error'])) {
077 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
078 }
079
080 $token = new StdOAuth2Token();
081 $token->setAccessToken($data['access_token']);
082
083 if (isset($data['expires_in'])) {
084 $token->setLifeTime($data['expires_in']);
085 }
086
087 if (isset($data['refresh_token'])) {
088 $token->setRefreshToken($data['refresh_token']);
089 unset($data['refresh_token']);
090 }
091
092 unset($data['access_token']);
093 unset($data['expires_in']);
094
095 $token->setExtraParams($data);
096
097 return $token;
098 }
099 }
100