本文整理汇总了PHP中Kurogo::popErrorReporting方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::popErrorReporting方法的具体用法?PHP Kurogo::popErrorReporting怎么用?PHP Kurogo::popErrorReporting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::popErrorReporting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveResponse
/**
* Retrieves the data using the config url. The default implementation uses the file_get_content()
* function to retrieve the request. Subclasses would need to implement this if a simple GET request
* is not sufficient (i.e. you need POST or custom headers).
* @return HTTPDataResponse a DataResponse object
*/
protected function retrieveResponse()
{
$this->initRequestIfNeeded();
if (!($this->requestURL = $this->url())) {
throw new KurogoDataException("URL could not be determined");
}
$this->requestParameters = $this->parameters();
if ($this->useCurl) {
$this->responseHeaders = array();
$this->requestMethod = $this->setCurlMethod();
$this->requestHeaders = $this->setCurlHeaders();
$this->requestData = $this->setCurlData();
} else {
$this->requestMethod = $this->setContextMethod();
$this->requestHeaders = $this->setContextHeaders();
$this->requestData = $this->setContextData();
}
Kurogo::log(LOG_INFO, "Retrieving {$this->requestURL}", 'url_retriever');
$url_parts = parse_url($this->requestURL);
if (!isset($url_parts['scheme'])) {
$this->DEFAULT_RESPONSE_CLASS = "FileDataResponse";
} else {
$this->DEFAULT_RESPONSE_CLASS = "HTTPDataResponse";
}
$response = $this->initResponse();
$response->setStartTime(microtime(true));
if (!$this->showWarnings) {
Kurogo::pushErrorReporting(E_ERROR);
}
if ($this->useCurl) {
$this->setCurlOption(CURLOPT_URL, $this->requestURL);
if ($file = $this->saveToFile()) {
$data = $this->cache->getFullPath($file);
$this->setCurlOption(CURLOPT_FILE, $data);
$result = curl_exec($this->curl);
} else {
$data = curl_exec($this->curl);
$response->setResponseError(curl_error($this->curl));
}
} else {
if ($file = $this->saveToFile()) {
$data = $this->cache->getFullPath($file);
$result = file_put_contents($data, file_get_contents($this->requestURL, false, $this->streamContext));
} else {
$data = file_get_contents($this->requestURL, false, $this->streamContext);
}
}
if (!$this->showWarnings) {
Kurogo::popErrorReporting();
}
$response->setEndTime(microtime(true));
if ($response instanceof HTTPDataResponse) {
$response->setRequest($this->requestMethod, $this->requestURL, $this->requestParameters, $this->requestHeaders, $this->requestData);
if ($this->useCurl) {
$response->setResponseHeaders($this->responseHeaders);
} else {
$http_response_header = isset($http_response_header) ? $http_response_header : array();
$response->setResponseHeaders($http_response_header);
}
Kurogo::log(LOG_DEBUG, sprintf("Returned status %d and %d bytes", $response->getCode(), strlen($data)), 'url_retriever');
} elseif ($response instanceof FileDataResponse) {
$response->setRequest($this->requestURL);
}
$response->setResponse($data);
if ($response->getResponseError()) {
Kurogo::log(LOG_WARNING, sprintf("%s for %s", $response->getResponseError(), $this->requestURL), 'url_retriever');
}
return $response;
}