-
Notifications
You must be signed in to change notification settings - Fork 25
/
run.php
88 lines (72 loc) · 1.8 KB
/
run.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
// SPDX-License-Identifier: GPL-2.0-only
require __DIR__."/src/KlikBCA/KlikBCA.php";
/**
* This contains $username and $password
*/
require __DIR__."/credentials.tmp";
define("COOKIE_FILE", __DIR__."/cookie.tmp");
/*
* Uncomment this define() to use proxy.
*/
// define("PROXY", "socks5://139.180.140.164:1080");
/**
* Show the account balance information.
*
* @param string $username
* @param string $password
* @return bool
*/
function show_balance($username, $password)
{
$bca = new KlikBCA\KlikBCA($username, $password, COOKIE_FILE);
/*
* Use proxy if the PROXY constant is defined.
*/
if (defined("PROXY"))
$bca->setProxy(PROXY);
$ret = $bca->login();
if (!$ret)
goto err;
$ret = $bca->balanceInquiry();
if (!$ret)
goto err;
printf("Balance information:\n%s\n\n",
json_encode($ret, JSON_PRETTY_PRINT));
return;
err:
printf("Error: %s\n", $bca->getErr());
}
show_balance($username, $password);
/**
* Show account statements given the date range.
*
* @param string $username
* @param string $password
* @param string $startDate
* @param string $endDate
* @return bool
*/
function show_account_statements($username, $password, $startDate, $endDate)
{
$bca = new KlikBCA\KlikBCA($username, $password, COOKIE_FILE);
/*
* Use proxy if the PROXY constant is defined.
*/
if (defined("PROXY"))
$bca->setProxy(PROXY);
$ret = $bca->login();
if (!$ret)
goto err;
$ret = $bca->accountStatement($startDate, $endDate);
if (!$ret)
goto err;
printf("Account statements for %s to %s:\n%s\n\n", $startDate, $endDate,
json_encode($ret, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
return;
err:
printf("Error: %s\n", $bca->getErr());
}
$startDate = "2022-04-25";
$endDate = "2022-05-01";
show_account_statements($username, $password, $startDate, $endDate);