35896-vm/api/search.php
Flatlogic Bot 897ddcfef1 1.2
2025-11-21 12:09:05 +00:00

84 lines
2.6 KiB
PHP

<?php
header('Content-Type: application/json');
// In a real app, you would query a database or an external API based on $_GET['query']
// For this mock, we'll just return a static result.
$query = isset($_GET['query']) ? trim($_GET['query']) : '';
// Simple validation example
if (empty($query)) {
echo json_encode(['error' => 'Query cannot be empty.']);
http_response_code(400);
exit;
}
// New, more detailed mock data for "HuisWiki"
$mock_data = [
// Basisgegevens
'adres' => 'Coolsingel 40, 3011 AD Rotterdam',
'postcode' => '3011 AD',
'plaats' => 'Rotterdam',
'gemeente' => 'Rotterdam',
'provincie' => 'Zuid-Holland',
'buurt' => 'Cool',
'wijk' => 'Stadsdriehoek',
// WOZ Waarde
'woz_waarde' => 2500000, // Current value in EUR
'woz_ontwikkeling' => [
['jaar' => 2019, 'waarde' => 2100000],
['jaar' => 2020, 'waarde' => 2200000],
['jaar' => 2021, 'waarde' => 2350000],
['jaar' => 2022, 'waarde' => 2400000],
['jaar' => 2023, 'waarde' => 2450000],
['jaar' => 2024, 'waarde' => 2500000],
],
// Kadastrale info
'perceelnummer' => 'RTD01-A-1234',
'eigendomssituatie' => 'Volledig eigendom',
'type' => 'Winkelpand',
'bouwjaar' => 1957,
'oppervlakte' => 1573, // in m²
// Energielabel
'energielabel' => getEnergylabelData('3011 AD', '40'),
'geschatte_energiekosten' => 450, // per maand
// Verkoophistorie
'verkoophistorie' => [
['datum' => '2012-05-20', 'prijs' => 1800000, 'type' => 'Verkocht'],
['datum' => '2005-11-15', 'prijs' => 1500000, 'type' => 'Verkocht'],
['datum' => '1998-01-30', 'prijs' => 950000, 'type' => 'Verkocht'],
],
// Buurtstatistieken
'buurtstatistieken' => [
'gemiddelde_woz' => 450000,
'inwoners' => 8500,
'gemiddelde_leeftijd' => 38,
'groen_score' => 7.2, // out of 10
'veiligheid_score' => 8.1, // out of 10
]
];
// Simulate network delay
sleep(1);
echo json_encode($mock_data);
function getEnergylabelData($zip, $number) {
// In a real app, you would get this from a secure place (e.g., environment variables)
$apiKey = getenv('ENERGIE_LABEL_API_KEY');
// If no API key is set, we can't continue.
if (!$apiKey || $apiKey === 'YOUR_API_KEY_HERE') {
// We return a placeholder for now, so the frontend knows to show the "API key needed" state.
return 'API_KEY_MISSING';
}
// TODO: Replace with actual API call to EP-Online using the $apiKey.
// For now, we'll return a mock value to prove the flow works.
return 'A++';
}