/** * Creates an OAuth request according to the current request. * * @return \Widop\Twitter\OAuth\OAuthRequest The OAuth request. */ public function createOAuthRequest() { $this->validateOptionBag($this->optionBag); $request = new OAuthRequest(); $request->setPath($this->getPath()); $request->setMethod($this->getMethod()); foreach ($this->optionBag as $option) { if (!$option->hasValue()) { continue; } switch ($option->getType()) { case OptionInterface::TYPE_PATH: $request->setPathParameter(':' . $option->getName(), $option->getNormalizedValue()); break; case OptionInterface::TYPE_GET: $request->setGetParameter($option->getName(), $option->getNormalizedValue()); break; case OptionInterface::TYPE_POST: $request->setPostParameter($option->getName(), $option->getNormalizedValue()); break; case OptionInterface::TYPE_FILE: $request->setFileParameter($option->getName() . '[]', $option->getNormalizedValue()); break; } } return $request; }
public function testUrlWithParameters() { $this->request->setBaseUrl('https://api.twitter.com/oauth'); $this->request->setPath('/statuses/show/:id.json'); $this->request->setPathParameter(':id', '123'); $this->request->setGetParameter('trim_user', true); $this->assertSame('https://api.twitter.com/oauth/statuses/show/123.json?trim_user=1', $this->request->getUrl()); }