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 |
SoundCloud.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 SoundCloud 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://api.soundcloud.com/');
19 }
20 }
21
22 /**
23 * @return \OAuth\Common\Http\Uri\UriInterface
24 */
25 public function getAuthorizationEndpoint()
26 {
27 return new Uri('https://soundcloud.com/connect');
28 }
29
30 /**
31 * @return \OAuth\Common\Http\Uri\UriInterface
32 */
33 public function getAccessTokenEndpoint()
34 {
35 return new Uri('https://api.soundcloud.com/oauth2/token');
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
56 if( isset( $data['expires_in'] ) ) {
57 $token->setLifetime( $data['expires_in'] );
58 unset( $data['expires_in'] );
59 }
60
61 if( isset($data['refresh_token'] ) ) {
62 $token->setRefreshToken( $data['refresh_token'] );
63 unset($data['refresh_token']);
64 }
65
66 unset( $data['access_token'] );
67
68 $token->setExtraParams( $data );
69
70 return $token;
71 }
72 }
73