Moinax\TvDb\Client::fetchZIP PHP Method

fetchZIP() protected method

Fetches data via curl and returns result
protected fetchZIP ( string $function, array $params = [], string $method = self::GET, string $file = null ) : string
$function string The function used to fetch data in zip
$params array
$method string
$file string The file to extract from the ZIP
return string The data
    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;
    }