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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Vkontakte.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.16 KiB


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