Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

Netatmo.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.10 KiB


 001  <?php
 002  /**
 003   * Netatmo service.
 004   *
 005   * @author  Pedro Amorim <contact@pamorim.fr>
 006   * @license http://www.opensource.org/licenses/mit-license.html MIT License
 007   *
 008   * @see    https://dev.netatmo.com/doc/
 009   */
 010   
 011  namespace OAuth\OAuth2\Service;
 012   
 013  use OAuth\Common\Consumer\CredentialsInterface;
 014  use OAuth\Common\Http\Client\ClientInterface;
 015  use OAuth\Common\Http\Exception\TokenResponseException;
 016  use OAuth\Common\Http\Uri\Uri;
 017  use OAuth\Common\Http\Uri\UriInterface;
 018  use OAuth\Common\Storage\TokenStorageInterface;
 019  use OAuth\OAuth2\Token\StdOAuth2Token;
 020   
 021  /**
 022   * Netatmo service.
 023   *
 024   * @author  Pedro Amorim <contact@pamorim.fr>
 025   * @license http://www.opensource.org/licenses/mit-license.html MIT License
 026   *
 027   * @see    https://dev.netatmo.com/doc/
 028   */
 029  class Netatmo extends AbstractService
 030  {
 031      /**
 032       * SCOPES.
 033       *
 034       * @see https://dev.netatmo.com/doc/authentication/scopes
 035       */
 036   
 037      // Used to read weather station's data (devicelist, getmeasure)
 038      const SCOPE_STATION_READ = 'read_station';
 039      // Used to read thermostat's data (devicelist, getmeasure, getthermstate)
 040      const SCOPE_THERMOSTAT_READ = 'read_thermostat';
 041      // Used to configure the thermostat (syncschedule, setthermpoint)
 042      const SCOPE_THERMOSTAT_WRITE = 'write_thermostat';
 043   
 044      public function __construct(
 045          CredentialsInterface $credentials,
 046          ClientInterface $httpClient,
 047          TokenStorageInterface $storage,
 048          $scopes = [],
 049          ?UriInterface $baseApiUri = null
 050      ) {
 051          parent::__construct(
 052              $credentials,
 053              $httpClient,
 054              $storage,
 055              $scopes,
 056              $baseApiUri,
 057              true // use parameter state
 058          );
 059   
 060          if (null === $baseApiUri) {
 061              $this->baseApiUri = new Uri('https://api.netatmo.net/');
 062          }
 063      }
 064   
 065      /**
 066       * {@inheritdoc}
 067       */
 068      public function getAuthorizationEndpoint()
 069      {
 070          return new Uri($this->baseApiUri . 'oauth2/authorize');
 071      }
 072   
 073      /**
 074       * {@inheritdoc}
 075       */
 076      public function getAccessTokenEndpoint()
 077      {
 078          return new Uri($this->baseApiUri . 'oauth2/token');
 079      }
 080   
 081      /**
 082       * {@inheritdoc}
 083       */
 084      protected function getAuthorizationMethod()
 085      {
 086          return static::AUTHORIZATION_METHOD_QUERY_STRING;
 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(
 100                  'Error in retrieving token: "' . $data['error'] . '"'
 101              );
 102          }
 103   
 104          $token = new StdOAuth2Token();
 105          $token->setAccessToken($data['access_token']);
 106          $token->setLifetime($data['expires_in']);
 107   
 108          if (isset($data['refresh_token'])) {
 109              $token->setRefreshToken($data['refresh_token']);
 110              unset($data['refresh_token']);
 111          }
 112   
 113          unset($data['access_token'], $data['expires_in']);
 114   
 115          $token->setExtraParams($data);
 116   
 117          return $token;
 118      }
 119  }
 120