Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
electronique:fournisseur-electricite-barry:barry-api.php [2021/03/03 21:16] – créée Cédric ABONNEL | electronique:fournisseur-electricite-barry:barry-api.php [2021/03/03 21:26] (Version actuelle) – Cédric ABONNEL | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | <code PHP> | ||
+ | <?PHP | ||
+ | |||
+ | $priceArea = array( | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | |||
+ | function getMethod($postData) { | ||
+ | // Le token suivant n'est pas valide. Il faut le modifier avec le votre, obtenu dans l' | ||
+ | $authToken = ' | ||
+ | $url = " | ||
+ | |||
+ | echo "< | ||
+ | echo '< | ||
+ | print_r(json_encode($postData)); | ||
+ | echo "</ | ||
+ | |||
+ | |||
+ | // Create the context for the request | ||
+ | $context = stream_context_create(array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | " | ||
+ | ' | ||
+ | ) | ||
+ | )); | ||
+ | |||
+ | // Send the request | ||
+ | $response = file_get_contents($url, | ||
+ | |||
+ | // Check for errors | ||
+ | if($response === FALSE){ | ||
+ | die(' | ||
+ | } | ||
+ | return $response; | ||
+ | } | ||
+ | |||
+ | |||
+ | function translateDate($strDate) { | ||
+ | $nomJourSemaineEN = array(" | ||
+ | $nomJourSemaineFR = array(" | ||
+ | $nomMoisEN = array(" | ||
+ | $nomMoisFR = array(" | ||
+ | $strDate = str_ireplace($nomMoisEN, | ||
+ | $strDate = str_ireplace($nomJourSemaineEN, | ||
+ | return $strDate; | ||
+ | } | ||
+ | |||
+ | |||
+ | setlocale(LC_ALL,' | ||
+ | |||
+ | // | ||
+ | $dateJour=date(' | ||
+ | $dateJourDemain=date(' | ||
+ | |||
+ | echo "< | ||
+ | echo "< | ||
+ | |||
+ | |||
+ | echo "< | ||
+ | |||
+ | // The data to send to the API getMeteringPoints | ||
+ | $postData = array(' | ||
+ | , ' | ||
+ | , ' | ||
+ | , ' | ||
+ | ); | ||
+ | |||
+ | $response = getMethod($postData); | ||
+ | // Decode the response | ||
+ | $responseData = json_decode($response, | ||
+ | |||
+ | echo "< | ||
+ | echo '< | ||
+ | print_r($responseData); | ||
+ | echo "</ | ||
+ | |||
+ | |||
+ | echo "< | ||
+ | |||
+ | // The data to send to the API getAggregatedConsumption | ||
+ | $postData = array(' | ||
+ | , ' | ||
+ | , ' | ||
+ | , ' | ||
+ | ); | ||
+ | |||
+ | $response = getMethod($postData); | ||
+ | // Decode the response | ||
+ | $responseData = json_decode($response, | ||
+ | |||
+ | echo "< | ||
+ | echo '< | ||
+ | print_r($responseData); | ||
+ | echo "</ | ||
+ | |||
+ | |||
+ | |||
+ | echo "< | ||
+ | |||
+ | // The data to send to the API getPrice | ||
+ | $postData = array(' | ||
+ | , ' | ||
+ | , ' | ||
+ | , ' | ||
+ | | ||
+ | ); | ||
+ | |||
+ | $response = getMethod($postData); | ||
+ | // Decode the response | ||
+ | $responseData = json_decode($response, | ||
+ | |||
+ | echo "< | ||
+ | echo '< | ||
+ | print_r($responseData); | ||
+ | echo "</ | ||
+ | |||
+ | </ |