gpt4 book ai didi

php - 如何使用 coinbase api 和 php 获取具有新地址的字符串

转载 作者:行者123 更新时间:2023-12-04 02:09:00 27 4
gpt4 key购买 nike

我正在尝试使用 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>";

?>

最佳答案

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

    <?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>";
?>

关于php - 如何使用 coinbase api 和 php 获取具有新地址的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40526109/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com