Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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
03 namespace OAuth\OAuth2\Service;
04
05 use OAuth\OAuth2\Token\StdOAuth2Token;
06 use OAuth\Common\Http\Exception\TokenResponseException;
07 use OAuth\Common\Http\Uri\Uri;
08 use OAuth\Common\Consumer\CredentialsInterface;
09 use OAuth\Common\Http\Client\ClientInterface;
10 use OAuth\Common\Storage\TokenStorageInterface;
11 use OAuth\Common\Http\Uri\UriInterface;
12
13 class Instagram extends AbstractService
14 {
15 /**
16 * Defined scopes
17 * @link http://instagram.com/developer/authentication/#scope
18 */
19 const SCOPE_BASIC = 'basic';
20 const SCOPE_PUBLIC_CONTENT = 'public_content';
21 const SCOPE_COMMENTS = 'comments';
22 const SCOPE_RELATIONSHIPS = 'relationships';
23 const SCOPE_LIKES = 'likes';
24 const SCOPE_FOLLOWER_LIST = 'follower_list';
25
26 public function __construct(
27 CredentialsInterface $credentials,
28 ClientInterface $httpClient,
29 TokenStorageInterface $storage,
30 $scopes = array(),
31 UriInterface $baseApiUri = null
32 ) {
33 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
34
35 if (null === $baseApiUri) {
36 $this->baseApiUri = new Uri('https://api.instagram.com/v1/');
37 }
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 public function getAuthorizationEndpoint()
44 {
45 return new Uri('https://api.instagram.com/oauth/authorize/');
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 public function getAccessTokenEndpoint()
52 {
53 return new Uri('https://api.instagram.com/oauth/access_token');
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 protected function getAuthorizationMethod()
60 {
61 return static::AUTHORIZATION_METHOD_QUERY_STRING;
62 }
63
64 /**
65 * {@inheritdoc}
66 */
67 protected function parseAccessTokenResponse($responseBody)
68 {
69 $data = json_decode($responseBody, true);
70
71 if (null === $data || !is_array($data)) {
72 throw new TokenResponseException('Unable to parse response.');
73 } elseif (isset($data['error'])) {
74 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
75 }
76
77 $token = new StdOAuth2Token();
78 $token->setAccessToken($data['access_token']);
79 // Instagram tokens evidently never expire...
80 $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
81 unset($data['access_token']);
82
83 $token->setExtraParams($data);
84
85 return $token;
86 }
87 }
88