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 |
Instagram.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 Instagram extends AbstractService
13 {
14 /**
15 * Defined scopes
16 * @link http://instagram.com/developer/authentication/#scope
17 */
18 const SCOPE_BASIC = 'basic';
19 const SCOPE_COMMENTS = 'comments';
20 const SCOPE_RELATIONSHIPS = 'relationships';
21 const SCOPE_LIKES = 'likes';
22
23 public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
24 {
25 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
26 if( null === $baseApiUri ) {
27 $this->baseApiUri = new Uri('https://api.instagram.com/v1/');
28 }
29 }
30
31 /**
32 * @return \OAuth\Common\Http\Uri\UriInterface
33 */
34 public function getAuthorizationEndpoint()
35 {
36 return new Uri('https://api.instagram.com/oauth/authorize/');
37 }
38
39 /**
40 * @return \OAuth\Common\Http\Uri\UriInterface
41 */
42 public function getAccessTokenEndpoint()
43 {
44 return new Uri('https://api.instagram.com/oauth/access_token');
45 }
46
47 /**
48 * Returns a class constant from ServiceInterface defining the authorization method used for the API
49 * Header is the sane default.
50 *
51 * @return int
52 */
53 protected function getAuthorizationMethod()
54 {
55 return static::AUTHORIZATION_METHOD_QUERY_STRING;
56 }
57
58 /**
59 * @param string $responseBody
60 * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth2\Token\StdOAuth2Token
61 * @throws \OAuth\Common\Http\Exception\TokenResponseException
62 */
63 protected function parseAccessTokenResponse($responseBody)
64 {
65 $data = json_decode( $responseBody, true );
66
67 if( null === $data || !is_array($data) ) {
68 throw new TokenResponseException('Unable to parse response.');
69 } elseif( isset($data['error'] ) ) {
70 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
71 }
72
73 $token = new StdOAuth2Token();
74
75 $token->setAccessToken( $data['access_token'] );
76 // Instagram tokens evidently never expire...
77 $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
78 unset( $data['access_token'] );
79 $token->setExtraParams( $data );
80
81 return $token;
82 }
83 }
84