3

我正在尝试使用 Coinbase 钱包 PHP 库(来自这里: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>";

?>
4

1 回答 1

4

所以,这就是它的工作原理,它生成一个新地址并打印它。

    <?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>";
?>
于 2016-11-10T15:18:03.230 回答