你好,我尝试制作一个 coinbase 钱包 api,它将用于自动发送付款作为 URL 从我的应用程序获取请求 仅使用 PHP,此代码中没有使用外部库 但是代码显示错误 404 即使我的 API 已启用并且我都尝试过 V2 V3
<?php
// Get the request parameters
$type = $_GET['type'];
$amount = $_GET['amount'];
$to = $_GET['to'];
$currency = $_GET['currency'];
// Check if the request is valid
if ($type !== 'send' || !is_numeric($amount) || !filter_var($to, FILTER_VALIDATE_EMAIL) || !in_array($currency, ['BTC', 'ETH', 'USDC'])) {
echo 'Invalid request';
exit;
}
// Create a Coinbase API client
$client = curl_init('https://api.coinbase.com/v3/');
curl_setopt($client, CURLOPT_HTTPHEADER, [
'Authorization: Bearer g3akagfskMRm0P5PE',
'Content-Type: application/json',
'X-Coinbase-API-Secret: o5FBZUPDvaJVnVXJmCKja-----+#WHHI',
]);
// Send the payment
$body = [
'amount' => $amount,
'currency' => $currency,
'recipient' => $to,
];
curl_setopt($client, CURLOPT_POSTFIELDS, json_encode($body));
// Get the response
$response = curl_exec($client);
// Check the response code
$code = curl_getinfo($client, CURLINFO_HTTP_CODE);
if ($code !== 200) {
echo 'Error: ' . $code;
exit;
}
// Decode the response body
$data = json_decode($response, true);
// Check if the payment was successful
if ($data['status'] === 'success') {
echo 'Payment sent successfully';
} else {
echo 'Error: ' . $data['error'];
}
// Close the connection
curl_close($client);
?>
试图自动发送付款但不起作用