0
https://coinbase.com/api/v1/transactions/send_money?api_key=xxx
我有這個網址,但在api_key參數之後接下來會發生什麼(我阻止了我的API密鑰,所以人們無法訪問我的BTC)?用Coinbase的API發送BTC?
有人可以給我一個如何正確使用coinbase的send_money API的例子嗎?
https://coinbase.com/api/v1/transactions/send_money?api_key=xxx
我有這個網址,但在api_key參數之後接下來會發生什麼(我阻止了我的API密鑰,所以人們無法訪問我的BTC)?用Coinbase的API發送BTC?
有人可以給我一個如何正確使用coinbase的send_money API的例子嗎?
我沒有PHP環境,方便使用來測試這一點,但我認爲這將是這樣的:
獲得他們的PHP庫:https://github.com/coinbase/coinbase-php
<?php
require_once(dirname(__FILE__) . '/../lib/Coinbase.php');
// Create an application at https://coinbase.com/oauth/applications and set these values accordingly
$_CLIENT_ID = "83a481f96bf28ea4bed1ee8bdc49ba4265609efa40d40477c2a57e913c479065";
$_CLIENT_SECRET = "a8dda20b94d09e84e8fefa5e7560133d9c5af9da93ec1d3e79ad0843d2920bbb";
// Note: your redirect URL should use HTTPS.
$_REDIRECT_URL = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$coinbaseOauth = new Coinbase_OAuth($_CLIENT_ID, $_CLIENT_SECRET, $_REDIRECT_URL);
if(isset($_GET['code'])) {
// Request tokens
$tokens = $coinbaseOauth->getTokens($_GET['code']);
// The user is now authenticated! Access and refresh tokens are in $tokens
// Store these tokens safely, and use them to make Coinbase API requests in the future.
// For example:
$coinbase = new Coinbase($coinbaseOauth, $tokens);
try {
echo 'Balance: ' . $coinbase->sendMoney($to, $amount, $notes=null, $userFee=null, $amountCurrency=null) . '<br>';
echo $coinbase->createButton("Alpaca socks", "10.00", "CAD")->embedHtml;
} catch (Coinbase_TokensExpiredException $e) {
$newTokens = $coinbaseOauth->refreshTokens($tokens);
// Store $newTokens and retry request
}
} else {
// Redirect to Coinbase authorization page
// The provided parameters specify the access your application will have to the
// user's account; for a full list, see https://coinbase.com/docs/api/overview
// You can pass as many scopes as you would like
echo "<a href=\"" . $coinbaseOauth->createAuthorizeUrl("balance", "buttons") . "\">Connect with Coinbase</a>";
}
這裏是匯款代碼
public function sendMoney($to, $amount, $notes=null, $userFee=null, $amountCurrency=null)
{
$params = array("transaction[to]" => $to);
if($amountCurrency !== null) {
$params["transaction[amount_string]"] = $amount;
$params["transaction[amount_currency_iso]"] = $amountCurrency;
} else {
$params["transaction[amount]"] = $amount;
}
if($notes !== null) {
$params["transaction[notes]"] = $notes;
}
if($userFee !== null) {
$params["transaction[user_fee]"] = $userFee;
}
return $this->post("transactions/send_money", $params);
}
當我谷歌'coinbase API文檔'我看到很多的例子。他們不適合你嗎? –
閱讀他們,除了他們沒有一個對我很有意義,我問了一個具體的問題。 – user2534566
我的代碼是針對他們的API,但不是用PHP編寫的。他們的樣品文件已經發布給我。所以如果文檔不幫你,我會檢查出他們的PHP庫https://github.com/coinbase/coinbase-php –