PHP 使用 Coinbase API 来获取当前余额并列出账户中的货币。它已经使用了几个星期,但是自从将一种货币换成 ETC(以太坊经典)后,余额忽略了这种货币。它适用于我尝试过的所有其他货币,所以 ETC 的特别之处在于 Coinbase 没有通过 API 恢复任何东西。coinbase 网站投资组合确实正确报告了 ETC 余额,所以这绝对是一个 API 问题。
<?php
include 'cfg.php'; // Contains API key
require_once ('vendor/autoload.php'); // Loads the API libraries
use Coinbase\Wallet\Client as Client;
use Coinbase\Wallet\Configuration as Configuration;
use Coinbase\Wallet\Enum\Param;
use Coinbase\Wallet\Resource\Transaction;
$configuration = Configuration::apiKey($cbase_API_Key, $cbase_API_Secret);
$client = Client::create($configuration);
$stime = $client->getTime();
echo '<h2> Server Time ' . $stime['iso'] . '</h2>';
$balance = 0.00;
$accounts = $client->getAccounts(); // Get the account(s)
echo '<table>';
foreach ( $accounts as $acct )
{
$amt = $acct->getBalance()->getAmount() ;
echo '<tr>';
echo '<td>' . $acct->getCurrency() . '</td>';
echo '<td>' . $acct->getName() . '</td>';
echo '<td>' . $acct->getBalance()->getAmount() . '</td>';
echo '<td>' . $acct->getNativeBalance()->getAmount() . '</td>';
echo '</tr>';
$balance = $balance + $acct->getNativeBalance()->getAmount();
}
echo '<table>';
echo '<h2> Total Balance: ' . $balance . '</h2>';
?>