17 if (is_array($input)) {
18 return array_map(array(
'ceLTIc\LTI\OAuth\OAuthUtil',
'urlencode_rfc3986'), $input);
19 } elseif (is_scalar($input)) {
20 return str_replace(
'+',
' ', str_replace(
'%7E',
'~', rawurlencode($input)));
31 return urldecode($string);
39 public static function split_header($header, $only_allow_oauth_parameters =
true)
42 if (preg_match_all(
'/(' . ($only_allow_oauth_parameters ?
'oauth_' :
'') .
'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header,
44 foreach ($matches[1] as $i => $h) {
47 if (isset($params[
'realm'])) {
48 unset($params[
'realm']);
58 if (function_exists(
'apache_request_headers')) {
61 $headers = apache_request_headers();
68 foreach ($headers AS $key => $value) {
69 $key = str_replace(
" ",
"-", ucwords(strtolower(str_replace(
"-",
" ", $key))));
76 if (isset($_SERVER[
'CONTENT_TYPE']))
77 $out[
'Content-Type'] = $_SERVER[
'CONTENT_TYPE'];
78 if (isset($_ENV[
'CONTENT_TYPE']))
79 $out[
'Content-Type'] = $_ENV[
'CONTENT_TYPE'];
81 foreach ($_SERVER as $key => $value) {
82 if (substr($key, 0, 5) ==
'HTTP_') {
86 $key = str_replace(
' ',
'-', ucwords(strtolower(str_replace(
'_',
' ', substr($key, 5)))));
99 if (!isset($input) || !$input)
102 $pairs = explode(
'&', $input);
104 $parsed_parameters = array();
105 foreach ($pairs as $pair) {
106 $split = explode(
'=', $pair, 2);
110 if (isset($parsed_parameters[$parameter])) {
114 if (is_scalar($parsed_parameters[$parameter])) {
117 $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
120 $parsed_parameters[$parameter][] = $value;
122 $parsed_parameters[$parameter] = $value;
126 return $parsed_parameters;
137 $params = array_combine($keys, $values);
141 uksort($params,
'strcmp');
144 foreach ($params as $parameter => $value) {
145 if (is_array($value)) {
149 sort($value, SORT_STRING);
150 foreach ($value as $duplicate_value) {
151 $pairs[] = $parameter .
'=' . $duplicate_value;
154 $pairs[] = $parameter .
'=' . $value;
160 return implode(
'&', $pairs);
static split_header($header, $only_allow_oauth_parameters=true)
static urlencode_rfc3986($input)
static build_http_query($params)
static urldecode_rfc3986($string)
Class to provide OAuth utility methods.
static parse_parameters($input)