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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Instagram.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.40 KiB


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