forked from bgaluszka/mbank
-
Notifications
You must be signed in to change notification settings - Fork 1
/
csv_export.php
47 lines (37 loc) · 1.31 KB
/
csv_export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Export as CSV
*/
require_once 'vendor/autoload.php';
use bgaluszka\Mbank\Mbank;
const MBANK_LOGIN = 'YOUR-LOGIN';
const MBANK_PASSWORD = 'YOUR-PASSWORD';
const MBANK_IBAN = 'ACCOUNT-IBAN';
const MBANK_DFP = 'ACCOUNT-DFP';
const MBANK_COOKIE8 = 'ACCOUNT-COOKIE8';
try {
$mbank = new Mbank();
// WARNING: Use constants, env variables or external configuration to
// store your bank credentials. Do NOT pass your l/p directly to login()
// method unless you want them to be exposed in case of any exception.
$mbank->login(MBANK_LOGIN, MBANK_PASSWORD, MBANK_DFP, MBANK_COOKIE8);
// export criteria
$criteria = array(
'daterange_from_day' => '1',
'daterange_from_month' => date('m'),
'daterange_from_year' => date('Y'),
'daterange_to_day' => date('d'),
'daterange_to_month' => date('m'),
'daterange_to_year' => date('Y'),
// we want to export incoming transfers only
'accoperlist_typefilter_group' => Mbank::TRANS_INCOMING,
);
// all transaction since beginning of given month
$csv = $mbank->export(MBANK_IBAN, $criteria);
$mbank->logout();
// you probably want to convert that to UTF-8
$csv = iconv('WINDOWS-1250', 'UTF-8', $csv);
file_put_contents('mbank.csv', $csv);
} catch (\RuntimeException $e) {
echo "{$e->getMessage()}\n";
}