/** * attempt to build up a request from what was passed to the server */ public static function fromRequest($httpMethod = NULL, $httpUrl = NULL, $parameters = NULL) { $scheme = !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" ? 'http' : 'https'; @$httpUrl or $httpUrl = $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; @$httpMethod or $httpMethod = $_SERVER['REQUEST_METHOD']; $requestHeaders = Oauth_Request::getHeaders(); /* 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 Oauth_Request($httpMethod, $httpUrl, $parameters); } else { /* Collect request parameters from query string (GET) and post-data * (POST) if appropriate (note: POST vars have priority) */ $reqParameters = $_GET; if ($httpMethod == "POST" && @strstr($requestHeaders["Content-Type"], "application/x-www-form-urlencoded")) { $reqParameters = array_merge($reqParameters, $_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($requestHeaders['Authorization'], 0, 6) == "OAuth ") { $headerParameters = Oauth_Request::splitHeader($requestHeaders['Authorization']); $parameters = array_merge($reqParameters, $headerParameters); $req = new Oauth_Request($httpMethod, $httpUrl, $parameters); } else { $req = new Oauth_Request($httpMethod, $httpUrl, $reqParameters); } } return $req; }