Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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 namespace OAuth\OAuth2\Service;
03
04 use OAuth\OAuth2\Token\StdOAuth2Token;
05 use OAuth\Common\Http\Exception\TokenResponseException;
06 use OAuth\Common\Http\Uri\Uri;
07 use OAuth\Common\Consumer\Credentials;
08 use OAuth\Common\Http\Client\ClientInterface;
09 use OAuth\Common\Storage\TokenStorageInterface;
10 use OAuth\Common\Http\Uri\UriInterface;
11
12 class Yammer extends AbstractService
13 {
14 public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
15 {
16 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
17 if( null === $baseApiUri ) {
18 $this->baseApiUri = new Uri('https://www.yammer.com/api/v1/');
19 }
20 }
21
22 /**
23 * @return \OAuth\Common\Http\Uri\UriInterface
24 */
25 public function getAuthorizationEndpoint()
26 {
27 return new Uri('https://www.yammer.com/dialog/oauth');
28 }
29
30 /**
31 * @return \OAuth\Common\Http\Uri\UriInterface
32 */
33 public function getAccessTokenEndpoint()
34 {
35 return new Uri('https://www.yammer.com/oauth2/access_token.json');
36 }
37
38 /**
39 * @param string $responseBody
40 * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth2\Token\StdOAuth2Token
41 * @throws \OAuth\Common\Http\Exception\TokenResponseException
42 */
43 protected function parseAccessTokenResponse($responseBody)
44 {
45 $data = json_decode( $responseBody, true );
46
47 if( null === $data || !is_array($data) ) {
48 throw new TokenResponseException('Unable to parse response.');
49 } elseif( isset($data['error'] ) ) {
50 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
51 }
52
53 $token = new StdOAuth2Token();
54 $token->setAccessToken( $data['access_token'] );
55 $token->setLifetime( $data['expires_in'] );
56
57 if( isset($data['refresh_token'] ) ) {
58 $token->setRefreshToken( $data['refresh_token'] );
59 unset($data['refresh_token']);
60 }
61
62 unset( $data['access_token'] );
63 unset( $data['expires_in'] );
64
65 $token->setExtraParams( $data );
66
67 return $token;
68 }
69
70 /**
71 * @return int
72 */
73 public function getAuthorizationMethod()
74 {
75 return static::AUTHORIZATION_METHOD_HEADER_BEARER;
76 }
77 }
78