Coinbase api 主要返回空数组
Coinbase api returning mostly empty arrey
我正在尝试测试 coinbase api。 Api 授权正常,但大多数函数都返回空数组,下面是我的代码示例
<?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
以外的所有回显打印空数组是输出截图
此问题已通过使用 $response=$client->decodeLastResponse(); 解决;并回显 $response
我正在尝试测试 coinbase api。 Api 授权正常,但大多数函数都返回空数组,下面是我的代码示例
<?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
以外的所有回显打印空数组是输出截图
此问题已通过使用 $response=$client->decodeLastResponse(); 解决;并回显 $response