本文整理汇总了PHP中HTTP_Request2_Response::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Request2_Response::setBody方法的具体用法?PHP HTTP_Request2_Response::setBody怎么用?PHP HTTP_Request2_Response::setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP_Request2_Response
的用法示例。
在下文中一共展示了HTTP_Request2_Response::setBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResponse
/**
* Send request to OSM server and return the response.
*
* @param string $url URL
* @param string $method GET (default)/POST/PUT
* @param string $user user (optional for read-only actions)
* @param string $password password (optional for read-only actions)
* @param string $body body (optional)
* @param array $post_data (optional)
* @param array $headers (optional)
*
* @access public
* @return HTTP_Request2_Response
* @todo Consider just returning the content?
* @throws Services_OpenStreetMap_Exception If something unexpected has
* happened while conversing with
* the server.
*/
public function getResponse($url, $method = HTTP_Request2::METHOD_GET, $user = null, $password = null, $body = null, array $post_data = null, array $headers = null)
{
$arguments = array($url, $method, $user, $password, $body, implode(":", (array) $post_data), implode(":", (array) $headers));
$id = md5(implode(":", $arguments));
$data = $this->cache->get($id);
if ($data) {
$response = new HTTP_Request2_Response();
$response->setStatus(200);
$response->setBody($data);
return $response;
}
$response = parent::getResponse($url, $method, $user, $password, $body, $post_data, $headers);
$this->cache->save($id, $response->getBody());
return $response;
}