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

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Bitrix24.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 3.20 KiB


 001  <?php
 002   
 003  namespace OAuth\OAuth2\Service;
 004   
 005  use OAuth\OAuth2\Token\StdOAuth2Token;
 006  use OAuth\Common\Http\Exception\TokenResponseException;
 007  use OAuth\Common\Http\Uri\Uri;
 008  use OAuth\Common\Consumer\CredentialsInterface;
 009  use OAuth\Common\Http\Client\ClientInterface;
 010  use OAuth\Common\Storage\TokenStorageInterface;
 011  use OAuth\Common\Http\Uri\UriInterface;
 012   
 013  class Bitrix24 extends AbstractService
 014  {
 015      const SCOPE_DEPARTMENT = 'department';
 016      const SCOPE_CRM = 'crm';
 017      const SCOPE_CALENDAR = 'calendar';
 018      const SCOPE_USER = 'user';
 019      const SCOPE_ENTITY = 'entity';
 020      const SCOPE_TASK = 'task';
 021      const SCOPE_TASKS_EXTENDED = 'tasks_extended';
 022      const SCOPE_IM = 'im';
 023      const SCOPE_LOG = 'log';
 024      const SCOPE_SONET_GROUP = 'sonet_group';
 025   
 026      /**
 027       * {@inheritdoc}
 028       */
 029      public function getAuthorizationEndpoint()
 030      {
 031          return new Uri(sprintf('%s/oauth/authorize/', $this->baseApiUri));
 032      }
 033   
 034      /**
 035       * {@inheritdoc}
 036       */
 037      public function getAccessTokenEndpoint()
 038      {
 039          return new Uri(sprintf('%s/oauth/token/', $this->baseApiUri));
 040      }
 041   
 042      /**
 043       * {@inheritdoc}
 044       */
 045      public function requestAccessToken($code, $state = null)
 046      {
 047          if (null !== $state) {
 048              $this->validateAuthorizationState($state);
 049          }
 050   
 051          $responseBody = $this->httpClient->retrieveResponse(
 052              $this->getAccessTokenUri($code),
 053              array(),
 054              $this->getExtraOAuthHeaders(),
 055              'GET'
 056          );
 057   
 058          $token = $this->parseAccessTokenResponse($responseBody);
 059          $this->storage->storeAccessToken($this->service(), $token);
 060   
 061          return $token;
 062      }
 063   
 064      /**
 065       * {@inheritdoc}
 066       */
 067      public function getAccessTokenUri($code)
 068      {
 069          $parameters = array(
 070              'code'          => $code,
 071              'client_id'     => $this->credentials->getConsumerId(),
 072              'client_secret' => $this->credentials->getConsumerSecret(),
 073              'redirect_uri'  => $this->credentials->getCallbackUrl(),
 074              'grant_type'    => 'authorization_code',
 075              'scope'         => $this->scopes
 076          );
 077   
 078          $parameters['scope'] = implode(' ', $this->scopes);
 079   
 080          // Build the url
 081          $url = $this->getAccessTokenEndpoint();
 082          foreach ($parameters as $key => $val) {
 083              $url->addToQuery($key, $val);
 084          }
 085   
 086          return $url;
 087      }
 088   
 089      /**
 090       * {@inheritdoc}
 091       */
 092      protected function parseAccessTokenResponse($responseBody)
 093      {
 094          $data = json_decode($responseBody, true);
 095   
 096          if (null === $data || !is_array($data)) {
 097              throw new TokenResponseException('Unable to parse response.');
 098          } elseif (isset($data['error'])) {
 099              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 100          }
 101   
 102          $token = new StdOAuth2Token();
 103          $token->setAccessToken($data['access_token']);
 104          $token->setLifetime($data['expires_in']);
 105   
 106          if (isset($data['refresh_token'])) {
 107              $token->setRefreshToken($data['refresh_token']);
 108              unset($data['refresh_token']);
 109          }
 110   
 111          unset($data['access_token']);
 112          unset($data['expires_in']);
 113   
 114          $token->setExtraParams($data);
 115   
 116          return $token;
 117      }
 118  }
 119