protected function fetchZIP($function, $params = array(), $method = self::GET, $file = null)
{
if (strpos($function, '.php') > 0) {
// no need of api key for php calls
$url = $this->getMirror(self::MIRROR_TYPE_ZIP) . '/api/' . $function;
} else {
$url = $this->getMirror(self::MIRROR_TYPE_ZIP) . '/api/' . $this->apiKey . '/' . $function;
}
$zipName = tempnam(sys_get_temp_dir(), "tvdb-");
$zip = fopen($zipName, "w");
fwrite($zip, $this->httpClient->fetch($url, $params, $method));
fclose($zip);
if (is_null($file)) {
$file = $this->getDefaultLanguage() . ".xml";
}
$dataPath = "zip://" . $zipName . "#" . $file;
$data = file_get_contents($dataPath);
$simpleXml = $this->getXml($data);
return $simpleXml;
}