I’m trying to create show transaction from Coinbase Api in php but I don’t get any response from the Coinbase api
<?php
function sendTransaction($private_key, $api_key , $transaction_id , $account_id){
$json = new stdClass();
$json->method = "GET";
$json->path = "/v2/accounts/".$account_id."/transactions/".$transaction_id."";
$json->secretapikey = $private_key;
$json->apikey = $api_key;
$body = new stdClass();
$body->type = "read";
$body->transaction_id = $transaction_id;
$result = json_encode($json);
$body = json_encode($body);
$time= time();
$sign = $time.$json->method.$json->path.$body;
$hmac = hash_hmac("SHA256", $sign, $json->secretapikey);
$header = array(
"CB-ACCESS-KEY:".$api_key,
"CB-ACCESS-SIGN:".$hmac,
"CB-ACCESS-TIMESTAMP:".time(),
"CB-VERSION:2019-11-15",
"Content-Type:application/json"
);
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
};
//Creating URL For Sending Request
$account_id = 'a2ae96db-c4f6-5364-b4d3-dd142af658c9'; //Coinbase Account ID
$private_key = 'QyxtlM3nKpI9E6U6aZXpIN**'; //Coinbase Private Key
$api_key = '4d13sW2jCJ**'; //Coinbase API KEY
$transaction_id = '1313a82c-10fc-532e-bc75-90801f482d74'; //Transaction id
$url = "https://api.coinbase.com/v2/accounts/".$account_id."/transactions/".$transaction_id."";
$tranx_id = sendTransaction(
$private_key,
$api_key,
$transaction_id,
$account_id
);
print_r($tranx_id);
?>
Here is the documentation url
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions

