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

twitter.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 2.57 KiB


001  <?php
002  /**
003   *
004   * This file is part of the phpBB Forum Software package.
005   *
006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
007   * @license GNU General Public License, version 2 (GPL-2.0)
008   *
009   * For full copyright and license information, please see
010   * the docs/CREDITS.txt file.
011   *
012   */
013   
014  namespace phpbb\auth\provider\oauth\service;
015   
016  /**
017   * Twitter OAuth service
018   */
019  class twitter extends base
020  {
021      /** @var \phpbb\config\config */
022      protected $config;
023   
024      /** @var \phpbb\request\request_interface */
025      protected $request;
026   
027      /**
028       * Constructor.
029       *
030       * @param \phpbb\config\config                $config        Config object
031       * @param \phpbb\request\request_interface    $request    Request object
032       */
033      public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
034      {
035          $this->config    = $config;
036          $this->request    = $request;
037      }
038   
039      /**
040       * {@inheritdoc}
041       */
042      public function get_service_credentials()
043      {
044          return [
045              'key'        => $this->config['auth_oauth_twitter_key'],
046              'secret'    => $this->config['auth_oauth_twitter_secret'],
047          ];
048      }
049   
050      /**
051       * {@inheritdoc}
052       */
053      public function perform_auth_login()
054      {
055          if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter))
056          {
057              throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
058          }
059   
060          $storage = $this->service_provider->getStorage();
061   
062          try
063          {
064              /** @var \OAuth\OAuth1\Token\TokenInterface $token */
065              $token = $storage->retrieveAccessToken('Twitter');
066          }
067          catch (\OAuth\Common\Storage\Exception\TokenNotFoundException $e)
068          {
069              throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
070          }
071   
072          $secret = $token->getRequestTokenSecret();
073   
074          try
075          {
076              // This was a callback request, get the token
077              $this->service_provider->requestAccessToken(
078                  $this->request->variable('oauth_token', ''),
079                  $this->request->variable('oauth_verifier', ''),
080                  $secret
081              );
082          }
083          catch (\OAuth\Common\Http\Exception\TokenResponseException $e)
084          {
085              throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
086          }
087   
088          // Send a request with it
089          $result = (array) json_decode($this->service_provider->request('account/verify_credentials.json'), true);
090   
091          // Return the unique identifier
092          return $result['id'];
093      }
094   
095      /**
096       * {@inheritdoc}
097       */
098      public function perform_token_auth()
099      {
100          if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter))
101          {
102              throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
103          }
104   
105          // Send a request with it
106          $result = (array) json_decode($this->service_provider->request('account/verify_credentials.json'), true);
107   
108          // Return the unique identifier
109          return $result['id'];
110      }
111  }
112