Your IP : 216.73.216.65


Current Path : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/AC/
Upload File :
Current File : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/AC/PVGISClient.php

<?php
class PVGISClient {
    private $baseUrl = 'https://re.jrc.ec.europa.eu/api/v5_3/seriescalc';

    public function getData($lat, $lon, $peakpower, $loss, $angle, $aspect) {
        $params = [
            'lat' => $lat,
            'lon' => $lon,
            'peakpower' => $peakpower,
            'loss' => $loss,
            'angle' => $angle,
            'aspect' => $aspect,
            'outputformat' => 'json',
            'pvtechchoice' => 'crystSi',
            'startyear' => '2020',
            'pvcalculation' => '1',
            
            
        ];

        $url = $this->baseUrl . '?' . http_build_query($params);
        
        $ctx = stream_context_create([
            'http' => [
                'timeout' => 5,
                'user_agent' => 'Mozilla/5.0'
            ]
        ]);

        $response = file_get_contents($url, false, $ctx);
        if ($response === false) {
            throw new Exception('Erreur lors de la récupération des données PVGIS');
        }

        return json_decode($response, true);
    }
}