1

我正在学习coinbase api并搞乱php。我似乎无法从数组中添加数据作为变量,因为数组是私有的。如何将私有值设置为变量?

$coinbaseconf = 配置::apiKey($coinbaseapi, $coinbasesecret); $client = Client::create($coinbaseconf);

返回

Coinbase\Wallet\Value\Money 对象([amount:Coinbase\Wallet\Value\Money:private] => 5567.17 [currency:Coinbase\Wallet\Value\Money:private] => GBP)

如果我尝试:

$var1 = $btcusdsellprice->金额;

获取错误

致命错误:未捕获错误:无法访问私有财产 Coinbase\Wallet\Value\Money::$amount in /var/www/html/xxx/xxx.php:22 堆栈跟踪:#0 {main} 在 /var/var 中抛出/www/html/xxx.php 第 22 行

4

1 回答 1

1

目前尚不清楚您到底要做什么,但可能如下:

use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
// creating a client to communicate with the API
$client = Client::create($configuration);

//use the client to request data from the api
$sellPrice = $client->getSellPrice('BTC-USD');

有关更多信息,您应该研究以下资源:

于 2018-05-30T09:20:53.147 回答