我正在尝试在 php.api 实现中使用 coinbase api 工作正常,我可以检查余额,创建新地址,所有这些都工作正常。但在请求比特币时遇到问题。我正在关注coinbase 官方 api 库,在提到的链接请求资金使用代码上的accroding文档是use Coinbase\Wallet\Enum\CurrencyCode;use Coinbase\Wallet\Resource\Transaction;use Coinbase\Wallet\Value\Money;$transaction = Transaction::request([ 'amount' => new Money(8, CurrencyCode::USD), 'description' => 'Burrito']);$client->createAccountTransaction($transaction);我完全按照他们说的使用了,但出现错误,下面是我的代码<?phprequire_once('vendor/autoload.php');use Coinbase\Wallet\Client;use Coinbase\Wallet\Configuration;use Coinbase\Wallet\Enum\CurrencyCode;use Coinbase\Wallet\Resource\Transaction;use Coinbase\Wallet\Value\Money;$apiKey='xxxxxxx';$apiSecret='xxxxxxx';$configuration = Configuration::apiKey($apiKey, $apiSecret);$client = Client::create($configuration);$transaction = Transaction::request([ 'amount' => new Money(8, CurrencyCode::USD), 'description' => 'Burrito']);$client->createAccountTransaction($transaction);echo json_encode($client->decodeLastResponse());?>错误是致命错误:未捕获的类型错误:传递给 Coinbase\Wallet\Client::createAccountTransaction() 的参数 1 必须是 Coinbase\Wallet\Resource\Account 的实例,给定的 Coinbase\Wallet\Resource\Transaction 实例,在 /file_path/file 中调用第 19 行的 .php 定义在 /library_path /vendor/coinbase/coinbase/src/Client.php:359 堆栈跟踪:#0 /file_path/file.php(19): Coinbase\Wallet\Client->createAccountTransaction(Object( Coinbase\Wallet\Resource\Transaction))1 {main} 在第 359 行的 /library_path /vendor/coinbase/coinbase/src/Client.php 中抛出
2 回答
潇潇雨雨
TA贡献1833条经验 获得超4个赞
尝试
$client->createAccountTransaction($account, $transaction);
Transaction::request([
'toEmail'=>'test@mail.com',
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($account, $transaction);
萧十郎
TA贡献1815条经验 获得超13个赞
您的电话还应参考$account:
$account = $client->getPrimaryAccount();
$transaction = Transaction::request([
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($account, $transaction);
- 2 回答
- 0 关注
- 143 浏览
添加回答
举报
0/150
提交
取消