本文整理汇总了PHP中Buzz\Message\Request::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getContent方法的具体用法?PHP Request::getContent怎么用?PHP Request::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Buzz\Message\Request
的用法示例。
在下文中一共展示了Request::getContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCurlOptsFromRequest
protected static function setCurlOptsFromRequest($curl, Message\Request $request)
{
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getMethod());
curl_setopt($curl, CURLOPT_URL, $request->getUrl());
curl_setopt($curl, CURLOPT_HTTPHEADER, $request->getHeaders());
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getContent());
}
示例2: isSpam
/**
* Tells if the data looks like spam
*
* @param array $data
* @return boolean
*/
public function isSpam(array $data)
{
$data['blog'] = $this->blogUrl;
$request = new Message\Request('POST', '/1.1/comment-check', $this->getHost());
$request->setContent(http_build_query($data));
$request->addHeader('Content-Type: application/x-www-form-urlencoded');
$request->addHeader(sprintf('Content-Length: %d', strlen($request->getContent())));
$response = new Message\Response();
$client = new Client\Curl();
$client->send($request, $response);
return 'true' == $response->getContent();
}
示例3: getPostFields
/**
* Returns a value for the CURLOPT_POSTFIELDS option.
*
* @return string|array A post fields value
*/
private static function getPostFields(Message\Request $request)
{
if (!$request instanceof Message\FormRequest) {
return $request->getContent();
}
$fields = $request->getFields();
$multipart = false;
foreach ($fields as $name => $value) {
if ($value instanceof Message\FormUpload) {
$multipart = true;
if ($file = $value->getFile()) {
// replace value with upload string
$fields[$name] = '@' . $file;
if ($contentType = $value->getContentType()) {
$fields[$name] .= ';type=' . $contentType;
}
} else {
return $request->getContent();
}
}
}
return $multipart ? $fields : http_build_query($fields);
}
示例4: makeContentHash
protected function makeContentHash(Request $request)
{
if ('POST' == $request->getMethod()) {
$body = $request->getContent();
return base64_encode(hash('sha256', $body, true));
}
return "";
}
示例5: getStreamContextArray
/**
* Converts a request into an array for stream_context_create().
*
* @param Message\Request $request A request object
*
* @return array An array for stream_context_create()
*/
public function getStreamContextArray(Message\Request $request)
{
return array('http' => array('method' => $request->getMethod(), 'header' => implode("\r\n", $request->getHeaders()), 'content' => $request->getContent(), 'protocol_version' => $request->getProtocolVersion(), 'ignore_errors' => $this->getIgnoreErrors(), 'max_redirects' => $this->getMaxRedirects(), 'timeout' => $this->getTimeout()));
}