Я использую CoinBase и пытаюсь получить данные, но в ответ получается, что плохие данные не могут быть сгенерированы даже в json или массив, а затем в json …
Код:
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Resource\Address;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$accounts = $client->getAccounts();
print_r($accounts); //Here is the response from down. But I dont know how to
get data from $accounts->data or anything else cause its not clear repsonse.
Ответ:
Coinbase\Wallet\Resource\ResourceCollection Object ( [previousUri:Coinbase\Wallet\Resource\ResourceCollection:private] => [nextUri:Coinbase\Wallet\Resource\ResourceCollection:private] => [resources:Coinbase\Wallet\Resource\ResourceCollection:private] => Array ( [0] => Coinbase\Wallet\Resource\Account Object ( [name:Coinbase\Wallet\Resource\Account:private] => LTC Wallet [primary:Coinbase\Wallet\Resource\Account:private] => [type:Coinbase\Wallet\Resource\Account:private] => wallet [currency:Coinbase\Wallet\Resource\Account:private] => LTC [balance:Coinbase\Wallet\Resource\Account:private] => Coinbase\Wallet\Value\Money Object ( [amount:Coinbase\Wallet\Value\Money:private] => 0 [currency:Coinbase\Wallet\Value\Money:private] => LTC ) [nativeBalance:Coinbase\Wallet\Resource\Account:private] => Coinbase\Wallet\Value\Money Object ( [amount:Coinbase\Wallet\Value\Money:private] => 0 [currency:Coinbase\Wallet\Value\Money:private] => EUR ) [createdAt:Coinbase\Wallet\Resource\Account:private] => DateTime Object ( [date] => 2017-11-16 12:00:19.000000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Coinbase\Wallet\Resource\Account:private] => DateTime Object ( [date] => 2018-01-17 19:10:56.000000 [timezone_type] => 2 [timezone] => Z ) [id:Coinbase\Wallet\Resource\Resource:private] => someID [resource:Coinbase\Wallet\Resource\Resource:private] => account [resourcePath:Coinbase\Wallet\Resource\Resource:private] => /v2/accounts/someID [rawData:Coinbase\Wallet\Resource\Resource:private] => Array ( [id] => someID [name] => LTC Wallet [primary] => [type] => wallet [currency] => LTC [balance] => Array ( [amount] => 1.00496384 [currency] => LTC ) [created_at] => 2017-11-16T12:00:19Z [updated_at] => 2018-01-17T19:10:56Z [resource] => account [resource_path] => /v2/accounts/someID [native_balance] => Array ( [amount] => 162.25 [currency] => EUR ) ) ) [1] => Coinbase\Wallet\Resource\Account Object ( [name:Coinbase\Wallet\Resource\Account:private] => ETH Wallet [primary:Coinbase\Wallet\Resource\Account:private] => [type:Coinbase\Wallet\Resource\Account:private] => wallet [currency:Coinbase\Wallet\Resource\Account:private] => ETH [balance:Coinbase\Wallet\Resource\Account:private] => Coinbase\Wallet\Value\Money Object ( [amount:Coinbase\Wallet\Value\Money:private] => 0 [currency:Coinbase\Wallet\Value\Money:private] => ETH ) [nativeBalance:Coinbase\Wallet\Resource\Account:private] => Coinbase\Wallet\Value\Money Object ( [amount:Coinbase\Wallet\Value\Money:private] => 0[currency:Coinbase\Wallet\Value\Money:private] => EUR ) [createdAt:Coinbase\Wallet\Resource\Account:private] => DateTime Object ( [date] => 2017-11-16 12:00:19.000000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Coinbase\Wallet\Resource\Account:private] => DateTime Object ( [date] => 2018-01-15 16:50:26.000000 [timezone_type] => 2 [timezone] => Z ) [id:Coinbase\Wallet\Resource\Resource:private] => someID [resource:Coinbase\Wallet\Resource\Resource:private] => account [resourcePath:Coinbase\Wallet\Resource\Resource:private] => /v2/accounts/someID [rawData:Coinbase\Wallet\Resource\Resource:private] => Array ( [id] => someID [name] => ETH Wallet [primary] => [type] => wallet [currency] => ETH [balance] => Array ( [amount] => 1.06493355 [currency] => ETH ) [created_at] => 2017-11-16T12:00:19Z [updated_at] => 2018-01-15T16:50:26Z [resource] => account [resource_path] => /v2/accounts/someID [native_balance] => Array ( [amount] => 942.46 [currency] => EUR ) ) ) [2] => Coinbase\Wallet\Resource\Account Object ( [name:Coinbase\Wallet\Resource\Account:private] => BTC Wallet [primary:Coinbase\Wallet\Resource\Account:private] => 1 [type:Coinbase\Wallet\Resource\Account:private] => wallet [currency:Coinbase\Wallet\Resource\Account:private] => BTC [balance:Coinbase\Wallet\Resource\Account:private] => Coinbase\Wallet\Value\Money Object ( [amount:Coinbase\Wallet\Value\Money:private] => 0 [currency:Coinbase\Wallet\Value\Money:private] => BTC ) [nativeBalance:Coinbase\Wallet\Resource\Account:private] => Coinbase\Wallet\Value\Money Object ( [amount:Coinbase\Wallet\Value\Money:private] => 0 [currency:Coinbase\Wallet\Value\Money:private] => EUR ) [createdAt:Coinbase\Wallet\Resource\Account:private] => DateTime Object ( [date] => 2017-11-16 12:00:19.000000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Coinbase\Wallet\Resource\Account:private] => DateTime Object ( [date] => 2018-01-19 21:32:51.000000 [timezone_type] => 2 [timezone] => Z ) [id:Coinbase\Wallet\Resource\Resource:private] => someID [resource:Coinbase\Wallet\Resource\Resource:private] => account [resourcePath:Coinbase\Wallet\Resource\Resource:private] => /v2/accounts/someID [rawData:Coinbase\Wallet\Resource\Resource:private] => Array ( [id] => someID [name] => BTC Wallet [primary] => 1 [type] => wallet [currency] => BTC [balance] => Array ( [amount] => 0.10962561 [currency] => BTC ) [created_at] => 2017-11-16T12:00:19Z [updated_at] => 2018-01-19T21:32:51Z [resource] => account [resource_path] => /v2/accounts/someID [native_balance] => Array ( [amount] => 1067.30 [currency] => EUR ) ) ) ) )
Я знаю, что он слишком большой, но я не могу найти способ получить все данные.
$data->data
$data["data"]
$data[0]
Ни один не работает ..
Ты можешь использовать
$data = $client->decodeLastResponse();
print_r($data);
это вернет массив со всеми необходимыми данными.
Других решений пока нет …