hi i am trying to make an api call using php however when i use the post method i get
{"message":"invalid signature"}
when i use the get method it works however i am not sure how to enter the extra arguments (id) if you could help me solve the post problem or recreate a get request with the parameter id i would be very great full
link to api documentation https://docs.pro.coinbase.com/
here is my code
$secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxx..............";
$key = 'xxxxxxxxxx.............';
$passphrase = 'xxxxxxx...';
$time = time();
$method = "POST";
$path = "/accounts";
$url = "https://api.prime.coinbase.com".$path;
$body = array(
'id' => "xxxxxxxxxxxxxx............"
);
$data = $time.$method.$path.json_encode($body);
$sign = base64_encode(hash_hmac("sha256", $data, base64_decode($secret),
true));
$headers = array(
'CB-ACCESS-KEY: '.$key,
'CB-ACCESS-SIGN: '.$sign,
'CB-ACCESS-TIMESTAMP: '.$time,
'CB-ACCESS-PASSPHRASE: '.$passphrase,
'Content-Type: application/json'
);
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
echo $res;