[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/auth/provider/oauth/service/ -> facebook.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\auth\provider\oauth\service;
  15  
  16  /**
  17  * Facebook OAuth service
  18  */
  19  class facebook extends base
  20  {
  21      /**
  22      * phpBB config
  23      *
  24      * @var \phpbb\config\config
  25      */
  26      protected $config;
  27  
  28      /**
  29      * phpBB request
  30      *
  31      * @var \phpbb\request\request_interface
  32      */
  33      protected $request;
  34  
  35      /**
  36      * Constructor
  37      *
  38      * @param    \phpbb\config\config                $config
  39      * @param    \phpbb\request\request_interface     $request
  40      */
  41  	public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
  42      {
  43          $this->config = $config;
  44          $this->request = $request;
  45      }
  46  
  47      /**
  48      * {@inheritdoc}
  49      */
  50  	public function get_service_credentials()
  51      {
  52          return array(
  53              'key'        => $this->config['auth_oauth_facebook_key'],
  54              'secret'    => $this->config['auth_oauth_facebook_secret'],
  55          );
  56      }
  57  
  58      /**
  59      * {@inheritdoc}
  60      */
  61  	public function perform_auth_login()
  62      {
  63          if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook))
  64          {
  65              throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
  66          }
  67  
  68          // This was a callback request, get the token
  69          $this->service_provider->requestAccessToken($this->request->variable('code', ''));
  70  
  71          // Send a request with it
  72          $result = json_decode($this->service_provider->request('/me'), true);
  73  
  74          // Return the unique identifier
  75          return $result['id'];
  76      }
  77  
  78      /**
  79      * {@inheritdoc}
  80      */
  81  	public function perform_token_auth()
  82      {
  83          if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook))
  84          {
  85              throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
  86          }
  87  
  88          // Send a request with it
  89          $result = json_decode($this->service_provider->request('/me'), true);
  90  
  91          // Return the unique identifier
  92          return $result['id'];
  93      }
  94  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1