[英]Printing bitcoin address transactions using blockchain API
我正在构建一个PHP网站,需要区块链API提供的某些功能( https://github.com/blockchain/api-v1-client-php )
我正在尝试打印出到特定地址完成的所有交易的概述,但到目前为止没有成功。
我已经收集了地址信息,但是交易记录存储在一个数组中(如文档中所写),并且无法将它们取出。
$limit = 50;
$offset = 0;
$address = "xxx";
$address_info = $Blockchain->Explorer->getAddress($address, $limit, $offset);
echo $address_info->n_tx; //just as a test, this works
$transactions = $address_info->transactions; //no error here
echo $transactions->version;
代码的最后一行抛出此错误:“试图获取非对象的属性”。 echo $ transactions [0]也无效。
github页面没有任何打印交易示例。
$ transactions的var_dump函数产生以下结果:
array (size=2)
0 =>
object(Blockchain\Explorer\Transaction)[11]
public 'double_spend' => boolean false
public 'block_height' => int 382334
public 'time' => int 1446833376
public 'lock_time' => int 0
public 'relayed_by' => string '192.99.2.32' (length=11)
public 'hash' => string 'd9f625afe46ea8bbe9dc74484cefbcb15fbd6887a1bc619b44161114b78ab038' (length=64)
public 'tx_index' => int 109866616
public 'version' => int 1
public 'size' => int 374
public 'inputs' =>
array (size=2)
0 =>
object(Blockchain\Explorer\Input)[12]
...
1 =>
object(Blockchain\Explorer\Input)[13]
...
public 'outputs' =>
array (size=2)
0 =>
object(Blockchain\Explorer\Output)[14]
...
1 =>
object(Blockchain\Explorer\Output)[15]
...
有任何想法吗?
$transactions
是一个PHP数组,而不是一个对象。 您可以使用$transactions[0]->version
访问数组中第一个对象的$transactions[0]->version
,或者使用诸如foreach ($transaction in $transactions) { ... }
类的方法foreach ($transaction in $transactions) { ... }
数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.