如何从block.io webhook获取数据?

时间:2016-08-18 17:24:05

标签: php json api bitcoin

我在我的localhost中使用了block.io api。我测试过基本钱包api,其中包含生成新地址,获取地址平衡,撤销等等。所有这些都运行正常,但我已经陷入了Real-Time Notifications API。我无法完成它。我已经设置了回拨网址,并且我使用testnet比特币网络进行测试。当事务发生时如何从POSTed通知中获取数据到我的callback.php页面? API向我发送像这样的JSON数据类型

{
"notification_id": "..."
"delivery_attempt": 1,
"created_at": 1426104819,
"type": "address",
"data": {
  "network": "BTC",
  "address": "3cBraN1Q...",
  "balance_change": "0.01000000", // net balance change, can be negative
  "amount_sent": "0.00000000",
  "amount_received": "0.01000000",
  "txid": "7af5cf9f2...", // the transaction's identifier (hash)
  "confirmations": X, // see below
  "is_green": false // was the transaction sent by a green address?
}
}

我的callback.php代码就是这个

require_once 'block.io/block_io.php';


$data = json_decode(file_get_contents('php://input'), true);


$type = $data['type'];
$network = $data['data']['network'];
$address = $data['data']['address'];
$balence_change = $data['data']['balance_change'];
$tx = $data['txid'];
$confirmations = $data['confirmations'];


echo 'Type: ' . $type;
echo 'Network: ' . $network;
echo 'Address: ' . $address;
echo 'Balance change: ' . $balance_change;
echo 'Confirmations: ' . $confirmations;

我使用testnet发送比特币然后刷新页面但没有返回任何内容。变量都是空的。请帮我完成这件事。 感谢

0 个答案:

没有答案