<!DOCTYPE html>
<html>
<?php
error_reporting(E_ALL);
ini_set("display_errors", 0);

$q      = urlencode($_REQUEST['q']);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-adresse.data.gouv.fr/search/?q=$q&limit=10",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Accept: */*",
        "Accept-Encoding: gzip, deflate",
        "Cache-Control: no-cache",
        "Connection: keep-alive",
        "Host: api-adresse.data.gouv.fr",
        "Postman-Token: d6f5f287-1f07-4580-a596-6166f5029dda,aa0c9e4c-40d7-4c4c-9f87-c42e8deffe91",
        "User-Agent: PostmanRuntime/7.18.0",
        "cache-control: no-cache"
    ),
));

$response = curl_exec($curl);
$json     = json_decode($response,TRUE);
$err      = curl_error($curl);
curl_close($curl);

if( count($json['features'])>0 ) {
    foreach ($json['features'] as $id => $Dtl) {
        $adr = $Dtl['properties']['label'];
        echo "- <a href='#' onmouseover=\"SaisieO('$adr')\" onclick=\"SaisieC('$adr')\" >" . $Dtl['properties']['label'] . "</a><br>";
    }
} else {
    echo "- <a href='#' onmouseover=\"SaisieO('')\" onclick=\"SaisieC('')\">Aucune adresse trouvée...</a><br>";
}

?>