$url = "https://blockchain.info/address/".$address."?format=json&offset=0";
$json = json_decode(file_get_contents($url), true);
$totalTxs = $json["n_tx"];
for($ex=0;$ex<$totalTxs;$ex+=50){
$url = "https://blockchain.info/address/".$address."?format=json&offset=$ex";
$json = json_decode(file_get_contents($url), true);
$totalTxs = $json["n_tx"];
$bal = $json["final_balance"];
$bitbal = $bal / 100000000;
$btc = number_format($bitbal, 8);
}
echo 'The balance is:'.$btc.' BTC';
The above flawlessly returns the balance of given $address.
for($i=0;$i<50;$i++){
$n_inputs = count($json["txs"][$i]["inputs"]);
for($ii = 0; $ii < $n_inputs; $ii++){
$totalVal = $json["txs"][$i]["inputs"][$ii]["prev_out"]["value"];
$amount = $totalVal / 100000000;
$sender = $json["txs"][$i]["inputs"][$ii]["prev_out"]["addr"];
$data .= "<span class='sender'>Sent From: ". $sender ." </span><span class='value'> AMOUNT: ".rtrim(number_format($amount, 8), '0') ."BTC </span>";
}
}
echo $data;
The above is my failed attempt to list the deposits and sending addresses to the given $address.
This lists countless addresses and desposits, some of which are transactions for $address - none of which seem to tell the sending address.
So how to I get the sending address, the txid relating to each transaction, and amount of each transaction without all the other noise?