Ejemplo n.º 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['REQUEST_URI'];
     @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
     $request_headers = apiClientOAuthRequest::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 apiClientOAuthRequest($http_method, $http_url, $parameters);
     } else {
         if (@substr($request_headers['Authorization'], 0, 5) == "OAuth") {
             $header_parameters = apiClientOAuthRequest::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 apiClientOAuthRequest($http_method, $http_url, $parameters);
         } else {
             if ($http_method == "GET") {
                 $req = new apiClientOAuthRequest($http_method, $http_url, $_GET);
             } else {
                 if ($http_method == "POST") {
                     $req = new apiClientOAuthRequest($http_method, $http_url, $_POST);
                 }
             }
         }
     }
     return $req;
 }