<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="UTF-8">
        <title>Appel de l'API en CURL</title>
    </head>
    <body>
        <h1>APPEL de l'adresse http://localhost/b1api/vol/liste</h1>
        <?php 
            // 
            $api_url = "http://localhost/b1api/vol/liste";
            $curl = curl_init($api_url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $response_json = curl_exec($curl);
            curl_close($curl);
            $ligne_de_resultat = json_decode($response_json);
            //print_r($response_json);
            //print_r($ligne_de_resultat);


            echo "<h2>Vol n°" . $ligne_de_resultat->id_vol . "</h2>";
            echo "<dl>";
            echo "<dt>de</dt><dd>" . $ligne_de_resultat->de . "</dd>";
            echo "<dt>à</dt><dd>" . $ligne_de_resultat->a . "</dd>";
            echo "<dt>via</dt><dd>" . $ligne_de_resultat->via . "</dd>";
            echo "<dt>Places restantes</dt><dd>" . ($ligne_de_resultat->places - $ligne_de_resultat->reservations) . "</dd>";
            echo "</dl>";            
        ?>
    </body>
</html>