PHP code example of lightools / fio

1. Go to this page and download the library: Download lightools/fio 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/ */

    

lightools / fio example snippets


$httpClient = new Bitbang\Http\Clients\CurlClient();
$xmlLoader = new Lightools\Xml\XmlLoader();

$fio = new Lightools\Fio\FioClient($xmlLoader, $httpClient);
$account = new Lightools\Fio\FioAccount('12345678', 'token', $fio); // no problem with having more Fio accounts

try {
    $transactions = $account->getNewTransactions();
    foreach ($transactions as $transaction) {
        echo $transaction->getVariableSymbol();
    }

} catch (Lightools\Fio\FioException $e) { // or catch specific exceptions
    $account->setBreakpointById($lastKnownMoveId);
    // further processing
}

try {
    $amount = 100;
    $currency = 'CZK';
    $accountTo = '12345678';
    $bankCode = '6100';
    $order = new Lightools\Fio\TransactionOrder($amount, $currency, $accountTo, $bankCode);
    $order->setVariableSymbol('8888');

    $account->sendOrders([$order]);

} catch (Lightools\Fio\FioTemporaryUnavailableException $e) {
    // Fio is overheated, wait 30 seconds and repeat

} catch (Lightools\Fio\FioWarningException $e) {
    // in this case, Fio accepted orders, but detected something suspicious

} catch (Lightools\Fio\FioFailureException $e) {
    // e.g. HTTP request failed, Fio is down, ...
}
sh
$ vendor/bin/tester -c tests/php.ini -d extension_dir=ext tests