Coinbase API返回大部分为空的arrey

时间:2019-07-03 08:01:23

标签: php arrays coinbase-api

我正在尝试测试coinbase API。 Api授权的罚款,但大多数函数都返回空Arrey,下面是我的代码示例

<?php
require_once('vendor/autoload.php');
use Coinbase\Wallet\Resource\Account;
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;
use Coinbase\Wallet\Resource\Address;

$apiKey='********';
$apiSecret='********;';

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);

$accounts = $client->getAccounts();
$account = $client->getPrimaryAccount();
$auth = $client->getCurrentAuthorization();
$user = $client->getCurrentUser();
$paymentMethods = $client->getPaymentMethods();

echo "accounts arrey". json_encode($accounts)."<hr/>";//empty arrey
echo "primary account arrey".json_encode($account)." <hr/>";//empty arrey
echo "current auth arrey".json_encode($auth)."<hr/>";//printing data perfectly
echo "current user arrey".json_encode($user)."<hr/>";//empty array 
echo "payment methods arrey".json_encode($paymentMethods)."<hr/>";//empty array 


?>   

$auth bellow外的所有回显打印空数组都是输出屏幕截图

output screenshot

1 个答案:

答案 0 :(得分:0)

通过使用$ response = $ client-> decodeLastResponse();解决了此问题。并回显$ response