I've been tearing my hair out for a while now. What I have so far is cribbed from the Coinbase Pro API documentation.
The Coinbase Pro API requires four different headers, one of them being a signature that's encrypted. I'm having issues forming a valid signature. According to the Coinbase Pro API Documentation:
<?php
// Your code here!
$request_path = "/accounts";
$secret = "ZSTJxPU6g9+QLITr5U4IeKWiaoCMqs9TFnCEavdvIjQOO/TqS4ZuRirtKLKUI4UBAen0TyBEsyDmzOZQQ6SC1w==";
$ch = curl_init("https://api.pro.coinbase.com/time");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch,CURLOPT_USERAGENT,'CoinbaseProAPI');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch));
curl_close($ch);
$timestamp = $result->epoch;
$timestamp_rounded = intval(ceil($timestamp));
$what = $timestamp_rounded.'GET'.$request_path;
$sig = base64_encode(hash_hmac("sha256", $what, base64_decode($secret), true));
$ch = curl_init("https://api.pro.coinbase.com".$request_path) ;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($ch,CURLOPT_USERAGENT,'CoinbaseProAPI');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'CB-ACCESS-KEY: 513194d14d510c48fd3ba86edef54969',
'CB-ACCESS-SIGN: '.$sig,
'CB-ACCESS-PASSPHRASE: bbujnpclpsv',
'CB-ACCESS-TIMESTAMP: '.$timestamp,
'Content-Type: application/json'));
$coinbasepro_response = curl_exec($ch) ;
curl_close($ch) ;
echo $coinbasepro_response;
?>
The response I'm getting is an invalid signature. I'm stumped, and any help is appreciated.