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 |
DeviantArt.php
01 <?php
02
03 namespace OAuth\OAuth2\Service;
04
05 use OAuth\Common\Consumer\CredentialsInterface;
06 use OAuth\Common\Http\Client\ClientInterface;
07 use OAuth\Common\Http\Exception\TokenResponseException;
08 use OAuth\Common\Http\Uri\Uri;
09 use OAuth\Common\Http\Uri\UriInterface;
10 use OAuth\Common\Storage\TokenStorageInterface;
11 use OAuth\OAuth2\Token\StdOAuth2Token;
12
13 class DeviantArt extends AbstractService
14 {
15 /**
16 * DeviantArt www url - used to build dialog urls.
17 */
18 const WWW_URL = 'https://www.deviantart.com/';
19
20 /**
21 * Defined scopes.
22 *
23 * If you don't think this is scary you should not be allowed on the web at all
24 *
25 * @see https://www.deviantart.com/developers/authentication
26 * @see https://www.deviantart.com/developers/http/v1/20150217
27 */
28 const SCOPE_FEED = 'feed';
29 const SCOPE_BROWSE = 'browse';
30 const SCOPE_COMMENT = 'comment.post';
31 const SCOPE_STASH = 'stash';
32 const SCOPE_USER = 'user';
33 const SCOPE_USERMANAGE = 'user.manage';
34
35 public function __construct(
36 CredentialsInterface $credentials,
37 ClientInterface $httpClient,
38 TokenStorageInterface $storage,
39 $scopes = [],
40 ?UriInterface $baseApiUri = null
41 ) {
42 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
43
44 if (null === $baseApiUri) {
45 $this->baseApiUri = new Uri('https://www.deviantart.com/api/v1/oauth2/');
46 }
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function getAuthorizationEndpoint()
53 {
54 return new Uri('https://www.deviantart.com/oauth2/authorize');
55 }
56
57 /**
58 * {@inheritdoc}
59 */
60 public function getAccessTokenEndpoint()
61 {
62 return new Uri('https://www.deviantart.com/oauth2/token');
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 protected function parseAccessTokenResponse($responseBody)
69 {
70 $data = json_decode($responseBody, true);
71
72 if (null === $data || !is_array($data)) {
73 throw new TokenResponseException('Unable to parse response.');
74 } elseif (isset($data['error'])) {
75 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
76 }
77
78 $token = new StdOAuth2Token();
79 $token->setAccessToken($data['access_token']);
80
81 if (isset($data['expires_in'])) {
82 $token->setLifeTime($data['expires_in']);
83 }
84
85 if (isset($data['refresh_token'])) {
86 $token->setRefreshToken($data['refresh_token']);
87 unset($data['refresh_token']);
88 }
89
90 unset($data['access_token'], $data['expires_in']);
91
92 $token->setExtraParams($data);
93
94 return $token;
95 }
96 }
97