我试图使用Coinbase Wallet PHP Library(从这里:https://github.com/coinbase/coinbase-php)。
$client->createAccountAddress($account, $address);
- 当我使用它时 - 创建新地址。但我想打印给客户。
$address = $client->getAccountAddress($account, $addressId);
- 我试图使用它,但我不知道要在$ addressId变量中添加什么。你能帮我吗?
我使用的代码示例:
<?php
require_once('vendor/autoload.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Resource\Address;
parse_str($_SERVER["QUERY_STRING"]);
$apiKey = 'myApi';
$apiSecret = 'apiSecret';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$account = $client->getPrimaryAccount();
$address = new Address([
'name' => 'New Address16'
]);
$client->createAccountAddress($account, $address);
$addresses = $client->getAccountAddress($account, $address); //i don't know what to put in second variable
echo "network: ".json_encode($addresses->getAddress)."<br>";
?>
答案 0 :(得分:2)
那就是它的工作原理,它会生成一个新地址并打印出来。
<?php
require_once('vendor/autoload.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Resource\Address;
parse_str($_SERVER["QUERY_STRING"]);
$apiKey = 'api';
$apiSecret = 'secret';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$account = $client->getPrimaryAccount();
$address = new Address([
'name' => 'New Address19'
]);
$add = $client->createAccountAddress($account, $address);
$addressId = $client->getAccountAddresses($account);
$addresses = $client->getAccountAddress($account, $addressId->getFirstId());
echo "Your address is: ".json_encode($addresses->getAddress())."<br>";
?>