Yngvarr

Generation

generate functionSat, 07 Jan 2023

return xml gz archive

function get_xml(){ $xml_doc = new DOMDocument(); $xml_doc->load("http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0"); $xml_string = $xml_doc->saveXML(); $filename = "xml_" . time(); $gzfilename = $filename . ".gz"; $fp = fopen($gzfilename, "w"); fwrite($fp, $xml_string); fclose($fp); $fd = fopen ($gzfilename, "r"); header("Content-Type: application/x-gzip"); header("Content-Disposition: attachment; filename=\"".$gzfilename."\""); fpassthru($fd); unlink($gzfilename); }

Questions about programming?Chat with your personal AI assistant