0
votes

Im learning coinbase api and messing around with php. I cant seem to add data as variable from array as array is private. How can i set private values as variable?

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

returns

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

if i try:

$var1 = $btcusdsellprice->amount;

Get error

Fatal error: Uncaught Error: Cannot access private property Coinbase\Wallet\Value\Money::$amount in /var/www/html/xxx/xxx.php:22 Stack trace: #0 {main} thrown in /var/var/www/html/xxx.php on line 22

1

1 Answers

1
votes

It is not really clear what exactly you are trying to do but it could be the following:

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');

For more information you should study the following resources: