/** * Format and sign an OAuth / API request * * @param string $url * @param string $method * @param array $parameters * * @return string * @throws TwitterOAuthException */ private function oAuthRequest($url, $method, array $parameters) { $request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters); if (array_key_exists('oauth_callback', $parameters)) { // Twitter doesn't like oauth_callback as a parameter. unset($parameters['oauth_callback']); } if ($this->bearer === null) { $request->signRequest($this->signatureMethod, $this->consumer, $this->token); $authorization = $request->toHeader(); } else { $authorization = 'Authorization: Bearer ' . $this->bearer; } return $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters); }