<?php
/*ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); 
error_reporting(E_ALL);*/
require __DIR__ . '/vendor/autoload.php';

require "library.php";
$apiKey = "AIzaSyAq1ODKKCVgTT3yvuqrsSIL8biDjhNu8NM";
$aiQuery = $_GET['query'];
$results = searchPlaces($aiQuery);
$jsonResponse = json_encode($results);
$resFile = "placejson/res_".time().".txt";
file_put_contents($resFile, $jsonResponse);

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($resFile) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($resFile));

readfile($resFile);
exit;