当前位置: 首页>>代码示例>>PHP>>正文


PHP Kurogo::popErrorReporting方法代码示例

本文整理汇总了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;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:75,代码来源:URLDataRetriever.php


注:本文中的Kurogo::popErrorReporting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。