/** * Request the page from IMDb * @param $url * @return string Page html. Empty string on failure */ protected function requestPage($url) { $this->logger->info("[Page] Requesting [{$url}]"); $req = new MDB_Request($url, $this->config); if (!$req->sendRequest()) { $this->logger->error("[Page] Failed to connect to server when requesting url [{$url}]"); return ''; } if (200 == $req->getStatus()) { return $req->getResponseBody(); } elseif ($redirectUrl = $req->getRedirect()) { $this->logger->debug("[Page] Following redirect from [{$url}] to [{$redirectUrl}]"); return $this->requestPage($redirectUrl); } else { $this->logger->error("[Page] Failed to retrieve url [{url}]. Response headers:{headers}", array('url' => $url, 'headers' => $req->getLastResponseHeaders())); return ''; } }
protected function debug_html($html) { $this->logger->error(htmlentities($html)); }