I am using the following code:
<?php
require_once 'vendor/autoload.php';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Resource\Address;
use Coinbase\Wallet\Resource\Account;
$apiKey = '**********';
$apiSecret = '*************';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
try {
$buyPrice = $client->getBuyPrice('BTC-USD');
} catch (Exception $exc) {
echo '<pre>';
echo $exc->getTraceAsString();
echo '<hr/>';
echo $exc->getMessage();
echo '</pre>';
}
?>
I get this error:
#0 C:\xampp\htdocs\coinbase\vendor\coinbase\coinbase\src\HttpClient.php(137): Coinbase\Wallet\Exception\HttpException::wrap(Object(GuzzleHttp\Exception\ClientException))
#1 C:\xampp\htdocs\coinbase\vendor\coinbase\coinbase\src\HttpClient.php(121): Coinbase\Wallet\HttpClient->send(Object(GuzzleHttp\Psr7\Request), Array)
#2 C:\xampp\htdocs\coinbase\vendor\coinbase\coinbase\src\HttpClient.php(74): Coinbase\Wallet\HttpClient->request('GET', '/v2/prices/BTC-...', Array)
#3 C:\xampp\htdocs\coinbase\vendor\coinbase\coinbase\src\Client.php(820): Coinbase\Wallet\HttpClient->get('/v2/prices/BTC-...', Array)
#4 C:\xampp\htdocs\coinbase\vendor\coinbase\coinbase\src\Client.php(118): Coinbase\Wallet\Client->getAndMapMoney('/v2/prices/BTC-...', Array)
#5 C:\xampp\htdocs\coinbase\index.php(16): Coinbase\Wallet\Client->getBuyPrice('BTC-USD')
#6 {main}
Client error: `GET https://api.coinbase.com/v2/prices/BTC-USD/buy` resulted in a `403 Forbidden` response: