You are here

function OAuthRequest::getNormalizedParams in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.2 lib/oauth-php/library/OAuthRequest.php \OAuthRequest::getNormalizedParams()

* Return the complete parameter string for the signature check. * All parameters are correctly urlencoded and sorted on name and value * *

Return value

string

1 call to OAuthRequest::getNormalizedParams()
OAuthRequest::signatureBaseString in lib/oauth-php/library/OAuthRequest.php
* Return the signature base string. * Note that we can't use rawurlencode due to specified use of RFC3986. * *

File

lib/oauth-php/library/OAuthRequest.php, line 332

Class

OAuthRequest
Object to parse an incoming OAuth request or prepare an outgoing OAuth request

Code

function getNormalizedParams() {

  /*
  		// sort by name, then by value
  		// (needed when we start allowing multiple values with the same name)
  		$keys   = array_keys($this->param);
  		$values = array_values($this->param);
  		array_multisort($keys, SORT_ASC, $values, SORT_ASC);
  */
  $params = $this->param;
  $normalized = array();
  ksort($params);
  foreach ($params as $key => $value) {

    // all names and values are already urlencoded, exclude the oauth signature
    if ($key != 'oauth_signature') {
      if (is_array($value)) {
        $value_sort = $value;
        sort($value_sort, SORT_STRING);

        // multi-parameters require the values to be sorted lexigraphically
        foreach ($value_sort as $v) {
          $normalized[] = $key . '=' . $v;
        }
      }
      else {
        $normalized[] = $key . '=' . $value;
      }
    }
  }
  return implode('&', $normalized);
}