-
Notifications
You must be signed in to change notification settings - Fork 51
/
06-list-payments.php
executable file
·34 lines (25 loc) · 1.07 KB
/
06-list-payments.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
<?php
require __DIR__ . '/../vendor/autoload.php';
use ZuluCrypto\StellarSdk\Server;
$server = Server::testNet();
$account = $server->getAccount('GA2C5RFPE6GCKMY3US5PAB6UZLKIGSPIUKSLRB6Q723BM2OARMDUYEJ5');
$currentCursor = null;
while (true) {
$resultsPerPage = 10;
$payments = $account->getPayments(null, $resultsPerPage);
$seenResults = 0;
foreach ($payments as $payment) {
/** @var $payment \ZuluCrypto\StellarSdk\Model\Operation|\ZuluCrypto\StellarSdk\Model\AssetTransferInterface */
// If the same cursor shows up twice, we're repeating results and should exit
if ($payment->getPagingToken() == $currentCursor) break 2;
printf('[%s] Amount: %s From %s in Tx %s' . PHP_EOL,
$payment->getAssetTransferType(),
$payment->getAssetAmount(),
$payment->getFromAccountId(),
$payment->getTransactionHash()
);
$currentCursor = $payment->getPagingToken();
}
// Immediate exit if there aren't enough results to fill the page
if ($seenResults < $resultsPerPage) break;
}