/** * Create OAuthRequest from Consumer and Token * * @param OAuthConsumer $consumer - OAuthConsumer * @param OAuthToken $token - OAuthToken * @param String $httpMethod - http method * @param String $httpURL - http URL * @param array|null $parameters - parameters * @return OAuthRequest */ public static function createFromConsumerAndToken($consumer, $token, $httpMethod, $httpURL, $parameters = null) { @$parameters or $parameters = array(); $nonce = OAuthRequest::generateNonce(); $timestamp = OAuthRequest::generateTimestamp(); $default = array('oauth_version' => OAuthRequest::VERSION, 'oauth_nonce' => $nonce, 'oauth_timestamp' => $timestamp, 'oauth_consumer_key' => $consumer->getKey()); if ($token) { $default['oauth_token'] = $token->getKey(); } $parameters = array_merge($default, $parameters); $urlParts = parse_url($httpURL); if (isset($urlParts['query']) && $urlParts['query']) { $params = OAuthUtils::parseParameterFromString($urlParts['query']); $parameters = array_merge($params, $parameters); } return new OAuthRequest($httpMethod, $httpURL, $parameters, $nonce, $timestamp); }