【问题标题】:Coinbase API getBalance ignoring ETC currencyCoinbase API getBalance 忽略 ETC 货币
【发布时间】:2021-04-17 13:01:22
【问题描述】:

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>';

?>

【问题讨论】:

  • 从 DNT 转换后,我现在使用 GRT 得到这个。该网站显示正确的信息,但 API 缺少交易的 GRT 结束。我检查了getTransactions,那里也没有 GRT 信息。像这样烦人的事情确实会使 API 变得不可靠。请帮忙。

标签: coinbase-api coinbase-php


【解决方案1】:

问题归结为分页:

因此,解决方法是将分页限制设置为 100(允许的最大值)。

默认为 24​​,因此返回的列表不完整。

$accounts = $client-&gt;getAccounts(['limit' =&gt; 100]);

【讨论】:

    猜你喜欢
    • 2021-12-16
    • 2020-11-22
    • 1970-01-01
    • 2021-08-02
    • 1970-01-01
    • 2018-05-02
    • 2018-03-05
    • 2022-01-14
    • 2020-09-29
    相关资源
    最近更新 更多