diff --git a/bb27b906-efd5-4c58-8370-e439b4bbedef/index.md b/bb27b906-efd5-4c58-8370-e439b4bbedef/index.md deleted file mode 100644 index 247f2cc..0000000 --- a/bb27b906-efd5-4c58-8370-e439b4bbedef/index.md +++ /dev/null @@ -1,114 +0,0 @@ -# Barry Api.php - -```PHP - '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 "
"; -``` \ No newline at end of file diff --git a/bb27b906-efd5-4c58-8370-e439b4bbedef/meta.json b/bb27b906-efd5-4c58-8370-e439b4bbedef/meta.json deleted file mode 100644 index 42deda2..0000000 --- a/bb27b906-efd5-4c58-8370-e439b4bbedef/meta.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "bb27b906-efd5-4c58-8370-e439b4bbedef", - "slug": "barry-api-php", - "title": "Barry Api.php", - "author": "cedric@abonnel.fr", - "published": true, - "published_at": "2021-03-03 21:26:26", - "created_at": "2021-03-03 21:26:26", - "updated_at": "2021-03-03 21:26:26", - "revisions": [], - "cover": "", - "files_meta": [], - "external_links": [], - "seo_title": "", - "seo_description": "", - "og_image": "", - "category": "Électronique" -}