You are here

class DrupalOAuthRequest in OAuth 1.0 7.3

Same name and namespace in other branches
  1. 6.3 includes/DrupalOAuthRequest.inc \DrupalOAuthRequest
  2. 7.4 includes/DrupalOAuthRequest.inc \DrupalOAuthRequest

Hierarchy

Expanded class hierarchy of DrupalOAuthRequest

File

includes/DrupalOAuthRequest.inc, line 3

View source
class DrupalOAuthRequest extends OAuthRequest {

  /**
   * Creates a OAuthRequest object from the current request
   *
   * @param string $http_method
   * @param string $http_url
   * @param array $parameters
   * @return OAuthRequest
   *  A OAuthRequest generated from the request
   */
  public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL) {

    // Preparations that has to be made if we're going to detect parameters
    if ($parameters == NULL) {
      $qs = $_SERVER['QUERY_STRING'];
      $q = $_GET['q'];

      // Unset $_GET['q'] if it was created by a redirect
      if (isset($_SERVER['REDIRECT_URL'])) {
        $q = FALSE;
      }
      elseif (isset($_GET['q'])) {
        $get = array();
        parse_str($_SERVER['QUERY_STRING'], $get);

        // The q parameter was in the original request, make sure it hasn't been altered
        if (isset($get['q'])) {
          $q = $get['q'];
        }
        else {
          $q = FALSE;
        }
      }
      $parsed = array();
      parse_str($_SERVER['QUERY_STRING'], $parsed);
      if ($q === FALSE) {
        unset($parsed['q']);
      }
      else {
        $parsed['q'] = $q;
      }
      $_SERVER['QUERY_STRING'] = http_build_query($parsed, '', '&');
    }
    $req = parent::from_request($http_method, $http_url, $parameters);

    // Restore $_SERVER['QUERY_STRING'] if it was touched
    if (isset($qs)) {
      $_SERVER['QUERY_STRING'] = $qs;
    }
    return $req;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalOAuthRequest::from_request public static function Creates a OAuthRequest object from the current request Overrides OAuthRequest::from_request
OAuthRequest::$base_string public property
OAuthRequest::$http_method protected property
OAuthRequest::$http_url protected property
OAuthRequest::$parameters protected property
OAuthRequest::$POST_INPUT public static property
OAuthRequest::$version public static property
OAuthRequest::build_signature public function
OAuthRequest::from_consumer_and_token public static function pretty much a helper function to set up the request
OAuthRequest::generate_nonce private static function util function: current nonce
OAuthRequest::generate_timestamp private static function util function: current timestamp
OAuthRequest::get_normalized_http_method public function just uppercases the http method
OAuthRequest::get_normalized_http_url public function parses the url and rebuilds it to be scheme://host/path
OAuthRequest::get_parameter public function
OAuthRequest::get_parameters public function
OAuthRequest::get_signable_parameters public function The request parameters, sorted and concatenated into a normalized string.
OAuthRequest::get_signature_base_string public function Returns the base string of this request
OAuthRequest::set_parameter public function
OAuthRequest::sign_request public function
OAuthRequest::to_header public function builds the Authorization: header
OAuthRequest::to_postdata public function builds the data one would send in a POST request
OAuthRequest::to_url public function builds a url usable for a GET request
OAuthRequest::unset_parameter public function
OAuthRequest::__construct function
OAuthRequest::__toString public function