示例#1
0
文件: Element.php 项目: mlntn/fpl-api
 protected function getContents($url, $headers = [], $as_html = false)
 {
     $key = $this->buildCacheKey($url);
     if (self::$cache->has($key)) {
         return self::$cache->get($key);
     }
     if ($as_html) {
         foreach ($headers as $k => $v) {
             $this->client->setHeader($k, $v);
         }
         $contents = $this->client->request('GET', $url)->html();
         foreach ($headers as $k => $v) {
             $this->client->removeHeader($k);
         }
     } else {
         $contents = file_get_contents($url);
     }
     self::$cache->set($key, $contents);
     return $contents;
 }