You are here

public static function DrupalOAuthRequest::from_request in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 includes/DrupalOAuthRequest.inc \DrupalOAuthRequest::from_request()
  2. 7.3 includes/DrupalOAuthRequest.inc \DrupalOAuthRequest::from_request()

Creates a OAuthRequest object from the current request

Parameters

string $http_method:

string $http_url:

array $parameters:

Return value

OAuthRequest A OAuthRequest generated from the request

Overrides OAuthRequest::from_request

4 calls to DrupalOAuthRequest::from_request()
oauth_common_callback_access_token in ./oauth_common.pages.inc
Get a access token for the request
oauth_common_callback_request_token in ./oauth_common.pages.inc
Generate a request token from the request.
oauth_common_form_authorize in ./oauth_common.pages.inc
Form for granting access to the consumer
oauth_common_verify_request in ./oauth_common.inc
Verifies the request

File

includes/DrupalOAuthRequest.inc, line 13

Class

DrupalOAuthRequest

Code

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;
}