38 if (isset($_SERVER[
'HTTP_X_FORWARDED_PROTO']) && ($_SERVER[
'HTTP_X_FORWARDED_PROTO'] ===
'https')) {
39 $_SERVER[
'HTTPS'] =
'on';
40 if (isset($_SERVER[
'HTTP_X_FORWARDED_HOST'])) {
41 $_SERVER[
'HTTP_HOST'] = $_SERVER[
'HTTP_X_FORWARDED_HOST'];
43 if ($_SERVER[
'SERVER_PORT'] == 80) {
44 $_SERVER[
'SERVER_PORT'] = 443;
47 $scheme = (!isset($_SERVER[
'HTTPS']) || $_SERVER[
'HTTPS'] !=
"on") ?
'http' :
'https';
49 '://' . $_SERVER[
'HTTP_HOST'] .
51 $_SERVER[
'SERVER_PORT'] .
52 $_SERVER[
'REQUEST_URI'];
65 if (isset($_SERVER[
'QUERY_STRING'])) {
71 if ((
$http_method ==
"POST" && isset($request_headers[
'Content-Type']) && stristr($request_headers[
'Content-Type'],
72 'application/x-www-form-urlencoded')) || !empty($_POST)) {
81 if (isset($request_headers[
'Authorization']) && substr($request_headers[
'Authorization'], 0, 6) ==
'OAuth ') {
97 'oauth_nonce' => OAuthRequest::generate_nonce(),
98 'oauth_timestamp' => OAuthRequest::generate_timestamp(),
99 'oauth_consumer_key' => $consumer->key);
101 $defaults[
'oauth_token'] = $token->key;
110 if ($allow_duplicates && isset($this->parameters[$name])) {
112 if (is_scalar($this->parameters[$name])) {
115 $this->parameters[$name] = array($this->parameters[$name]);
118 $this->parameters[$name][] = $value;
120 $this->parameters[$name] = $value;
126 return isset($this->parameters[$name]) ? $this->parameters[$name] :
null;
136 unset($this->parameters[$name]);
150 if (isset($params[
'oauth_signature'])) {
151 unset($params[
'oauth_signature']);
174 return implode(
'&', $parts);
182 return strtoupper($this->http_method);
191 $parts = parse_url($this->http_url);
193 $scheme = (isset($parts[
'scheme'])) ? $parts[
'scheme'] :
'http';
194 $port = (isset($parts[
'port'])) ? $parts[
'port'] : (($scheme ==
'https') ?
'443' :
'80');
195 $host = (isset($parts[
'host'])) ? strtolower($parts[
'host']) :
'';
196 $path = (isset($parts[
'path'])) ? $parts[
'path'] :
'';
198 if (($scheme ==
'https' && $port !=
'443') || ($scheme ==
'http' && $port !=
'80')) {
199 $host =
"$host:$port";
202 return "$scheme://$host$path";
213 $out .=
'?' . $post_data;
237 $out =
'Authorization: OAuth';
240 foreach ($this->parameters as $k => $v) {
241 if (substr($k, 0, 5) !=
"oauth")
246 $out .= ($first) ?
' ' :
',';
265 "oauth_signature_method", $signature_method->get_name(), false
267 $signature = $this->
build_signature($signature_method, $consumer, $token);
273 $signature = $signature_method->build_signature($this, $consumer, $token);
280 private static function generate_timestamp()
288 private static function generate_nonce()
293 return md5($mt . $rand);
build_signature($signature_method, $consumer, $token)
static split_header($header, $only_allow_oauth_parameters=true)
static urlencode_rfc3986($input)
to_postdata()
builds the data one would send in a POST request
Class to represent an OAuth Exception.
to_url()
builds a url usable for a GET request
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
static build_http_query($params)
to_header($realm=null)
builds the Authorization: header
get_normalized_http_url()
parses the url and rebuilds it to be scheme://host/path
static from_request($http_method=null, $http_url=null, $parameters=null)
attempt to build up a request from what was passed to the server
Class to represent an OAuth Request.
__construct($http_method, $http_url, $parameters=null)
static parse_parameters($input)
get_normalized_http_method()
just uppercases the http method
set_parameter($name, $value, $allow_duplicates=true)
get_signature_base_string()
Returns the base string of this request.
get_signable_parameters()
The request parameters, sorted and concatenated into a normalized string.
sign_request($signature_method, $consumer, $token)