PHP code example of endeken / ofx-php-parser
1. Go to this page and download the library: Download endeken/ofx-php-parser 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/ */
endeken / ofx-php-parser example snippets
ndeken\OFX;
try {
// Load the OFX data
$ofxData = file_get_contents('path_to_your_ofx_file.ofx');
// Parse the OFX data
$parsedData = OFX::parse($ofxData);
// $parsedData is an instance of OFXData which gives you access to all parsed data
// Access the sign-on status code
$statusCode = $parsedData->signOn->status->code;
// Accessing bank accounts data
$bankAccounts = $parsedData->bankAccounts;
foreach($bankAccounts as $account) {
echo 'Account ID: ' .$account->accountNumber . PHP_EOL;
echo 'Bank ID: ' .$account->routingNumber . PHP_EOL;
// Loop through each transaction
foreach ($account->statement->transactions as $transaction) {
echo 'Transaction Type: ' . $transaction->type . PHP_EOL;
echo 'Date: ' . $transaction->date . PHP_EOL;
echo 'Amount: ' . $transaction->amount . PHP_EOL;
}
}
} catch (Exception $e) {
echo 'An error occurred: ' . $e->getMessage();
}
bash
$ composer