Coinbase api2数据作为php中的变量

时间:2018-05-30 08:50:13

标签: php api coinbase-api coinbase-php

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

  

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

返回

  

Coinbase \ Wallet \ Value \ Money Object(   [金额:Coinbase \ Wallet \ Value \ Money:private] => 5567.17   [货币:Coinbase \ Wallet \ Value \ Money:private] => GBP)

如果我尝试:

  

$ var1 = $ btcusdsellprice->金额;

获取错误

  

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

1 个答案:

答案 0 :(得分: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');

有关详细信息,请研究以下资源: