$address, "key" => $_ENV["GOOGLE_SERVER_API_KEY"], "region" => $region, ]; $url = "https://maps.googleapis.com/maps/api/geocode/json?" . http_build_query($query); $string = @file_get_contents($url); $object = json_decode($string); if(!$object) { throw new RuntimeException("Failed to validate address."); } if($object->status !== "OK") { throw new RuntimeException("Failed to validate address."); } return $object->results; } }