在调用此方法之前,您必须在客户端上调用 enableActiveRecord()

You must call enableActiveRecord() on your client before calling this method

我正在使用 coinbase-php 库。

我正在尝试使用以下代码获取主帐户的地址。

$primaryAccount = $this->client->getPrimaryAccount();
$addresses = $primaryAccount->getAddresses();

出现 "enableActiveRecord() on your client before calling this method" 错误。

在使用该代码段之前,我应该通过

启用 ActiveRecord
$this->client->enableActiveRecord();

不久之后

$this->client = Client::create($this->configuration);

试试这个,希望对您有所帮助。

将帐户设为主帐户。

示例请求:

curl https://api.coinbase.com/v2/accounts/82de7fcd-db72-5085-8ceb-bee19303080b/primary
  -X POST
  -H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c'

Response (200)
{
   "data": 
   {
      "id": "82de7fcd-db72-5085-8ceb-bee19303080b",
      "name": "New hot wallet",
      "primary": true,
      "type": "wallet",
      "currency": "BTC",
      "balance": 
      {
         "amount": "0.00000000",
         "currency": "BTC"
      },
      "native_balance": 
      {
         "amount": "0.00",
         "currency": "USD"
      },
      "created_at": "2015-03-31T15:21:58-07:00",
      "updated_at": "2015-03-31T15:21:58-07:00",
      "resource": "account",
      "resource_path": "/v2/accounts/82de7fcd-db72-5085-8ceb-bee19303080b"
   }
}