/** * returns the response body of GET request * * @param string $url * * @since ADD MVC 0.5 */ public function get_body($url) { $this->init($url); if (!is_string($url)) { throw new e_developer("Invalid " . __CLASS__ . "->" . __FUNCTION__ . "() parameter ", $url); } curl_setopt($this->curl, CURLOPT_REFERER, $url); if ($this->enable_cache) { $cache_path = $this->cache_path(); if (!file_exists($cache_path)) { $response = $this->exec(); if ($response) { file_put_contents($cache_path, $response); e_system::assert(file_exists($cache_path) && !is_dir($cache_path), "Failed to cache {$cache_path}"); } else { throw new e_developer("Failed to fetch {$this->url}", array($this, $cache_path)); } } if (file_exists($cache_path) && !is_dir($cache_path)) { $response = file_get_contents($cache_path); } else { $response = null; } } else { $response = $this->exec(); } return $response; }
/** * Handle exception * */ public function handle_exception() { $this->message = str_replace(add::config()->root_dir, '< mvc-path >', $this->data->message); return parent::handle_exception(); }