1. Go to this page and download the library: Download nieknijland/ista-php 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/ */
nieknijland / ista-php example snippets
use NiekNijland\Ista\Ista;
$ista = new Ista(
username: '[email protected]',
password: 'your-password',
);
// Fetch all consumption data
$userValues = $ista->getUserValues();
$customer = $userValues->customers[0];
foreach ($customer->consumption->services as $service) {
echo "Current usage: {$service->totalNow}\n";
echo "Previous year: {$service->totalPrevious}\n";
foreach ($service->currentMeters as $meter) {
echo " {$meter->position}: {$meter->value}\n";
}
}
$ista = new Ista(
username: '[email protected]',
password: 'your-password',
httpClient: $customGuzzleClient, // ?ClientInterface, default: new Client()
cache: $psr16Cache, // ?CacheInterface (PSR-16), default: null (no caching)
cacheTtl: 3600, // int, cache TTL in seconds, default: 3600
);
$ista = new Ista(
username: '[email protected]',
password: 'your-password',
cache: new YourPsr16Cache(),
cacheTtl: 86400, // 24 hours
);
use NiekNijland\Ista\Exception\IstaException;
try {
$result = $ista->getUserValues();
} catch (IstaException $e) {
// Authentication failures, HTTP errors, malformed responses
// Original exception is available via $e->getPrevious()
}
use NiekNijland\Ista\Testing\FakeIsta;
use NiekNijland\Ista\Testing\UserValuesResultFactory;
$fake = new FakeIsta();
$fake->seedUserValuesResult(UserValuesResultFactory::make());
$result = $fake->getUserValues();
$fake->assertCalled('getUserValues');
$fake->assertCalledTimes('getUserValues', 1);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.