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 |
Yammer.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 Yammer extends AbstractService
14 {
15 public function __construct(
16 CredentialsInterface $credentials,
17 ClientInterface $httpClient,
18 TokenStorageInterface $storage,
19 $scopes = [],
20 ?UriInterface $baseApiUri = null
21 ) {
22 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
23
24 if (null === $baseApiUri) {
25 $this->baseApiUri = new Uri('https://www.yammer.com/api/v1/');
26 }
27 }
28
29 /**
30 * {@inheritdoc}
31 */
32 public function getAuthorizationEndpoint()
33 {
34 return new Uri('https://www.yammer.com/dialog/oauth');
35 }
36
37 /**
38 * {@inheritdoc}
39 */
40 public function getAccessTokenEndpoint()
41 {
42 return new Uri('https://www.yammer.com/oauth2/access_token.json');
43 }
44
45 /**
46 * {@inheritdoc}
47 */
48 public function getAuthorizationMethod()
49 {
50 return static::AUTHORIZATION_METHOD_HEADER_BEARER;
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 protected function parseAccessTokenResponse($responseBody)
57 {
58 $data = json_decode($responseBody, true);
59
60 if (null === $data || !is_array($data)) {
61 throw new TokenResponseException('Unable to parse response.');
62 } elseif (isset($data['error'])) {
63 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
64 }
65
66 $token = new StdOAuth2Token();
67 $token->setAccessToken($data['access_token']['token']);
68 $token->setLifetime($data['access_token']['expires_at']);
69
70 if (isset($data['refresh_token'])) {
71 $token->setRefreshToken($data['refresh_token']);
72 unset($data['refresh_token']);
73 }
74
75 unset($data['access_token'], $data['expires_in']);
76
77 $token->setExtraParams($data);
78
79 return $token;
80 }
81 }
82