Example #1
0
 /**
  * attempt to build up a request from what was passed to the server
  */
 public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL)
 {
     /*{{{*/
     $scheme = !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" ? 'http' : 'https';
     @$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
     @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
     $request_headers = OAuthRequest::get_headers();
     // let the library user override things however they'd like, if they know
     // which parameters to use then go for it, for example XMLRPC might want to
     // do this
     if ($parameters) {
         $req = new OAuthRequest($http_method, $http_url, $parameters);
     } else {
         // collect request parameters from query string (GET) and post-data (POST) if appropriate (note: POST vars have priority)
         $req_parameters = $_GET;
         if ($http_method == "POST" && @strstr($request_headers["Content-Type"], "application/x-www-form-urlencoded")) {
             $req_parameters = array_merge($req_parameters, $_POST);
         }
         // next check for the auth header, we need to do some extra stuff
         // if that is the case, namely suck in the parameters from GET or POST
         // so that we can include them in the signature
         if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
             $header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
             $parameters = array_merge($req_parameters, $header_parameters);
             $req = new OAuthRequest($http_method, $http_url, $parameters);
         } else {
             $req = new OAuthRequest($http_method, $http_url, $req_parameters);
         }
     }
     return $req;
 }
Example #2
0
 /**
  * attempt to build up a request from what was passed to the server
  */
 public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL)
 {
     /*{{{*/
     @$http_url or $http_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
     $request_headers = OAuthRequest::get_headers();
     // let the library user override things however they'd like, if they know
     // which parameters to use then go for it, for example XMLRPC might want to
     // do this
     if ($parameters) {
         $req = new OAuthRequest($http_method, $http_url, $parameters);
     } else {
         if (@substr($request_headers['Authorization'], 0, 5) == "OAuth") {
             $header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
             if ($http_method == "GET") {
                 $req_parameters = $_GET;
             } else {
                 if ($http_method = "POST") {
                     $req_parameters = $_POST;
                 }
             }
             $parameters = array_merge($header_parameters, $req_parameters);
             $req = new OAuthRequest($http_method, $http_url, $parameters);
         } else {
             if ($http_method == "GET") {
                 $req = new OAuthRequest($http_method, $http_url, $_GET);
             } else {
                 if ($http_method == "POST") {
                     $req = new OAuthRequest($http_method, $http_url, $_POST);
                 }
             }
         }
     }
     return $req;
 }
Example #3
0
	/**
	 * attempt to build up a request from what was passed to the server
	 */
	public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
		@$http_url or $http_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];

		$request_headers = OAuthRequest::get_headers();

		// let the library user override things however they'd like, if they know
		// which parameters to use then go for it, for example XMLRPC might want to
		// do this
		if ($parameters) {
			$req = new OAuthRequest($http_method, $http_url, $parameters);
		}
		// next check for the auth header, we need to do some extra stuff
		// if that is the case, namely suck in the parameters from GET or POST
		// so that we can include them in the signature
		else if (@substr($request_headers['Authorization'], 0, 5) == "OAuth") {
			$header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
			if ($http_method == "GET") {
				$req_parameters = $_GET;
			}
			else if ($http_method = "POST") {
				$req_parameters = $_POST;
			}
			$parameters = array_merge($header_parameters, $req_parameters);
			$req = new OAuthRequest($http_method, $http_url, $parameters);
		}
		else if ($http_method == "GET") {
			$req = new OAuthRequest($http_method, $http_url, $_GET);
		}
		else if ($http_method == "POST") {
			$req = new OAuthRequest($http_method, $http_url, $_POST);
		}
		return $req;
	}
Example #4
0
 /**
  * attempt to build up a request from what was passed to the server
  */
 function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL)
 {
     /*{{{*/
     @$http_url or $http_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
     // we need this to get the actual Authorization: header
     // because apache tends to tell us it doesn't exist
     $request_headers = apache_request_headers();
     // let the library user override things however they'd like, if they know
     // which parameters to use then go for it, for example XMLRPC might want to
     // do this
     if ($parameters) {
         $req = new OAuthRequest($http_method, $http_url, $parameters);
     } else {
         if (@substr($request_headers['Authorization'], 0, 5) == "OAuth") {
             $header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
             if ($http_method == "GET") {
                 $req_parameters = $_GET;
             } else {
                 if ($http_method = "POST") {
                     $req_parameters = $_POST;
                 }
             }
             $parameters = array_merge($header_parameters, $req_parameters);
             $req = new OAuthRequest($http_method, $http_url, $parameters);
         } else {
             if ($_GET['oauth_version'] || $_GET['oauth_token']) {
                 $req = new OAuthRequest($http_method, $http_url, $_GET);
             } else {
                 //must return an OAuthRequest, even if empty, so just use this
                 $req = new OAuthRequest($http_method, $http_url, $_POST);
             }
         }
     }
     return $req;
 }
Example #5
0
 /**
  * attempt to build up a request from what was passed to the server
  */
 public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL)
 {
     /*{{{*/
     $scheme = !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" ? 'http' : 'https';
     @$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
     $request_headers = OAuthRequest::get_headers();
     // let the library user override things however they'd like, if they know
     // which parameters to use then go for it, for example XMLRPC might want to
     // do this
     if ($parameters) {
         $req = new OAuthRequest($http_method, $http_url, $parameters);
     } else {
         if (@substr($request_headers['Authorization'], 0, 5) == "OAuth") {
             $header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
             if ($http_method == "GET") {
                 $req_parameters = $_GET;
             } else {
                 if ($http_method == "POST") {
                     $req_parameters = $_POST;
                 }
             }
             $parameters = array_merge($header_parameters, $req_parameters);
             $req = new OAuthRequest($http_method, $http_url, $parameters);
         } else {
             if ($http_method == "GET") {
                 $req = new OAuthRequest($http_method, $http_url, $_GET);
             } else {
                 if ($http_method == "POST" && $_SERVER['CONTENT_TYPE'] == 'text/xml') {
                     // XML-RPC
                     $req = new OAuthRequest($http_method, $http_url, $_GET);
                     //XXX until there's xoauth_body_signature
                 } else {
                     if ($http_method == "POST") {
                         $req = new OAuthRequest($http_method, $http_url, $_POST);
                     }
                 }
             }
         }
     }
     return $req;
 }