本文整理汇总了PHP中Guzzle\Http\Message\Request::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setBody方法的具体用法?PHP Request::setBody怎么用?PHP Request::setBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::setBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send the request
*/
public function send()
{
// make a request object
$this->request = $this->client->createRequest($this->method, $this->host . $this->resource);
// set headers
foreach ($this->headers as $header => $value) {
$this->request->setHeader($header, $value);
}
// set body
if (!empty($this->body)) {
$this->request->setBody($this->body);
}
try {
// finally send the request
$this->response = $this->client->send($this->request);
} catch (BadResponseException $e) {
$this->response = $this->request->getResponse();
}
$this->sent = true;
}
示例2: setBody
/**
* Function to set given file parameters
* on the request
*
* @param array $params File parameters to set
*/
public function setBody($body, $contentType = null)
{
if (method_exists($this->request, 'setBody')) {
$this->request->setBody($body, $contentType);
}
}