'DK_NORDPOOL_SPOT_DK1', 'fr' => 'FR_EPEX_SPOT_FR' ); function getMethod($postData) { // Le token suivant n'est pas valide. Il faut le modifier avec le votre, obtenu dans l'application Barry Eenrgy $authToken = 'Bx6Da6v0h34MM7OhAjCaN9zak+IZLNe9tUlCebw7+LiP8+5SH6BcdNrOY85s9q7Sdfrmc/yyjWrJROlJ9vhlRCYY310TsHcGNodMzr3cGfZOwVYNPYWxGxcZHO94p6W98SJC/TdIYhsE+tRnvMMKHktTdkRjmMolHAtWpYyFzDw='; $url = "https://jsonrpc.barry.energy/json-rpc"; echo "
";
  echo '

La méthode appelée :

'; print_r(json_encode($postData)); echo "

"; // Create the context for the request $context = stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => "Authorization: Bearer {$authToken}\r\n". "Content-Type: application/json\r\n", 'content' => json_encode($postData) ) )); // Send the request $response = file_get_contents($url, FALSE, $context); // Check for errors if($response === FALSE){ die('Error'); } return $response; } function translateDate($strDate) { $nomJourSemaineEN = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); $nomJourSemaineFR = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"); $nomMoisEN = array("January","February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $nomMoisFR = array("Janvier","Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); $strDate = str_ireplace($nomMoisEN, $nomMoisFR, $strDate); $strDate = str_ireplace($nomJourSemaineEN, $nomJourSemaineFR, $strDate); return $strDate; } setlocale(LC_ALL,'fr'); //$dateJour=date('d F Y', strtotime('31-12-2018')); $dateJour=date('d F Y'); $dateJourDemain=date('d F Y', strtotime('+1 day', strtotime($dateJour))); echo "

Métriques de Barry Energy

"; echo "

Rapport établi le ".translateDate(date('l d F Y'))." à ".date('H:i:s')."

"; echo "

Etat de l'abonnement

"; // The data to send to the API getMeteringPoints $postData = array('method' => 'co.getbarry.api.v1.OpenApiController.getMeteringPoints' , 'id' => 0 , 'jsonrpc' => '2.0' , 'params' => array() ); $response = getMethod($postData); // Decode the response $responseData = json_decode($response, TRUE); echo "
";
echo '

La réponse :

'; print_r($responseData); echo "
"; echo "

Consommation du $dateJour

"; // The data to send to the API getAggregatedConsumption $postData = array('method' => 'co.getbarry.api.v1.OpenApiController.getAggregatedConsumption' , 'id' => 0 , 'jsonrpc' => '2.0' , 'params' => array(date(DATE_ATOM, strtotime($dateJour)), date(DATE_ATOM, strtotime($dateJourDemain))) ); $response = getMethod($postData); // Decode the response $responseData = json_decode($response, TRUE); echo "
";
echo '

La réponse :

'; print_r($responseData); echo "
"; echo "

Prix du $dateJour

"; // The data to send to the API getPrice $postData = array('method' => 'co.getbarry.api.v1.OpenApiController.getPrice' , 'id' => 0 , 'jsonrpc' => '2.0' , 'params' => array($priceArea['fr'], date(DATE_ATOM, strtotime($dateJour)), date(DATE_ATOM, strtotime($dateJourDemain)) ) ); $response = getMethod($postData); // Decode the response $responseData = json_decode($response, TRUE); echo "
";
echo '

La réponse :

'; print_r($responseData); echo "
";