1. Go to this page and download the library: Download xvilo/greenchoice library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xvilo / greenchoice example snippets
declare(strict_types=1);
use Greenchoice\HttpClient\Plugin\Authentication\GrantType\Password;
leApp',
'A6E60EBF73521F57',
'xxxxx-xxx-xxx-xxxx-xxxxxxxxxx',
new Password(),
'[email protected]',
'S0mes3c#password'
);
// Authenticate
$client->authenticate($clientToken['access_token']);
// Get contracts
$contracts = $client->customer->getContracts();
if (count($contracts) === 0) {
die('No contracts found for this customer');
}
$contractId = $contracts[0]['Id'];
$customerId = $contracts[0]['Klantnummer'];
echo sprintf("Using contract[ID=%s] for customer[ID=%s]", $contractId, $customerId) . PHP_EOL;
// Get approved contract
$approvedContract = $client->contracts->getApproved($contractId);
echo sprintf("Contract[ID=%s] has %s approved contract(s)", $contractId, count($approvedContract)) . PHP_EOL;
// Get contract features
$contractFeatures = $client->features->getByContractId($contractId);
echo sprintf("Contract[ID=%s] has %s contract feature(s)", $contractId, count($contractFeatures)) . PHP_EOL;
// Get contract counters
$contractCounters = $client->readings->getCounters($contractId);
echo sprintf("For contract[ID=%s] there is %s registered meter(s)", $contractId, count($contractCounters)) . PHP_EOL;
// get contract readings
$contractReadings = $client->readings->getCounterData($contractId);
echo sprintf("Last known meter readings since: \n\n - %s:\n - high: %s\n - low: %s", $contractReadings[0]['DatumInvoer'], $contractReadings[0]['MeterstandenOutput'][0]['Hoog'], $contractReadings[0]['MeterstandenOutput'][0]['Laag']) . PHP_EOL;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.