Пример #1
0
function run($accounts)
{
    require 'IbParser.php';
    $notifier = new IbParser();
    $datadir = dirname(__FILE__) . '/data';
    if (!is_dir($datadir)) {
        mkdir($datadir);
    }
    // Langkah-langkah untuk setiap akun
    foreach ($accounts as $account) {
        // Periksa file data, kalau false langsung lanjut ke akun berikut
        if (!($balance = checkDataFile($account, $datadir))) {
            continue;
        }
        // Ambil balance, kalau false langsung lanjut
        if (!($new_balance = $notifier->getBalance($account[0], $account[1], $account[2]))) {
            continue;
        }
        $balance = json_decode($balance)->balance;
        // Update file data walaupun balancenya sama
        updateDataFile($account, $datadir, $new_balance);
        // Bandingkan balance, kalau sama langsung lanjut
        if ($balance == $new_balance) {
            continue;
        }
        // Ambil transaksi
        $transactions = $notifier->getTransactions($account[0], $account[1], $account[2]);
        // Kirim email
        notify($account, $balance, $new_balance, $transactions);
    }
}
Пример #2
0
<?php 
error_reporting(E_ALL);
require 'IbParser.php';
$parser = new IbParser();
?>

<?php 
$bank = 'BCA';
$user = '******';
$pass = '******';
$balance = $parser->getBalance($bank, $user, $pass);
?>

<?php 
$transactions = $parser->getTransactions($bank, $user, $pass);
?>

<?php 
function convert_to_csv($input_array, $output_file_name, $delimiter)
{
    /** open raw memory as file, no need for temp files, be careful not to run out of memory thought */
    $f = fopen('php://memory', 'w');
    /** loop through array  */
    foreach ($input_array as $line) {
        /** default php csv handler **/
        fputcsv($f, $line, $delimiter);
    }
    /** rewrind the "file" with the csv lines **/
    fseek($f, 0);
    /** modify header to be downloadable csv file **/