区块链API v1异常"未找到"

时间:2016-06-06 08:45:57

标签: php bitcoin blockchain

我已按照此处https://github.com/blockchain/service-my-wallet-v3所述安装了本地服务,并且已成功启动。但是,当我想要平衡我的钱包时:

$Blockchain = new \Blockchain\Blockchain();
$Blockchain->setServiceUrl("http://localhost:3000");
$Blockchain->Wallet->credentials('myid', 'mypass');
$stats = $Blockchain->Stats->get();
var_dump($stats);
$balance = $Blockchain->Wallet->getBalance();
var_dump($balance);     

我收到以下异常消息:

Fatal error: Uncaught exception 'Blockchain\Exception\ApiError' with message 'No
t found' in C:\xampp\htdocs\test\Blockchain\Blockchain.php:114
Stack trace:
#0 C:\xampp\htdocs\test\Blockchain\Wallet\Wallet.php(47): Blockchain\Blockchain-
>post('merchant/16d72a...', Array)
#1 C:\xampp\htdocs\test\Blockchain\Wallet\Wallet.php(55): Blockchain\Wallet\Wall
et->call('balance')
#2 C:\xampp\htdocs\test\wallet.php(26): Blockchain\Wallet\Wallet->getBalance()
#3 {main}
  thrown in C:\xampp\htdocs\test\Blockchain\Blockchain.php on line 114

导致此问题的原因以及如何解决?谢谢!

2 个答案:

答案 0 :(得分:1)

我很困惑你在哪里提出这些功能? setServiceURL() credentials() getBalance()

您使用的是自定义库还是包装器?

钱包服务处理发送到您告诉它运行的端口上的localhost上的服务的GET请求。

以下是一个例子:

$url = "http://127.0.0.1:3000/merchant/YOUR-GUID/address_balance?address=1someBitcoinAddy&password=YOUR-PASSWORD&api_code=YOUR-API-CODE";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$ccc = curl_exec($ch);
$json = json_decode($ccc, true);
echo "<pre>";
var_dump($json);
echo "</pre>";

可在其API文档页面上找到可用GET命令的列表:https://blockchain.info/api/blockchain_wallet_api

答案 1 :(得分:-1)

像这样创建对象

$Blockchain = new \Blockchain\Blockchain('http://localhost:3000', $my_api_code);