Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace IMSGlobal\LTI\OAuth;
   4  
   5  /**
   6   * Class to represent an %OAuth Token
   7   *
   8   * @copyright  Andy Smith
   9   * @version 2008-08-04
  10   * @license https://opensource.org/licenses/MIT The MIT License
  11   */
  12  #[\AllowDynamicProperties]
  13  class OAuthToken {
  14  
  15      // access tokens and request tokens
  16      public $key;
  17      public $secret;
  18  
  19      /**
  20       * key = the token
  21       * secret = the token secret
  22       */
  23      function __construct($key, $secret) {
  24          $this->key = $key;
  25          $this->secret = $secret;
  26      }
  27  
  28      /**
  29       * generates the basic string serialization of a token that a server
  30       * would respond to request_token and access_token calls with
  31       */
  32      function to_string() {
  33          return 'oauth_token=' .
  34                 OAuthUtil::urlencode_rfc3986($this->key) .
  35                 '&oauth_token_secret=' .
  36                 OAuthUtil::urlencode_rfc3986($this->secret);
  37      }
  38  
  39      function __toString() {
  40          return $this->to_string();
  41      }
  42  
  43  }