Author

Topic: Blockchain.info PHP Parse (Read 704 times)

sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
January 08, 2015, 01:11:53 AM
#1
SOLVED

I need help with some JSON Parsing using PHP...
I'll show you the code first then tell you where my problem lies.
Code:
$address "1CaiKQcVSF2hY5sHgtirfK5ytLSZHXkxB2";
        
$ch curl_init(); 

        
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
        
curl_setopt($chCURLOPT_URL"https://blockchain.info/address/$address?filter=1&format=json");

        
$output curl_exec($ch); 

        
curl_close($ch);      

        
$a=json_decode($output,TRUE);
?>


    
        
        
        
        
    
=1?>
if (is_array($a["txs"])) { ?>
    foreach ($a["txs"] as $tx) { ?>
        

            
            
            
            
        
    ?>
?>

            #
        

            Date Sent
        

            Address(es)
        

            Amount Sent
        

                ($counter++); ?>
            

                (date("Y-m-d",$tx["time"])); ?>
            

                ($tx["out"][0]["addr"]); ?>
            

$inputs = $tx["inputs"][0]["prev_out"]; $value=0;
foreach($inputs as $num=>$inDetails){
     if($inDetails["addr"]==$address){
         $value=$inDetails["value"];
     }
}
?>
                (round($value/1000000004)); ?>BTC (($tx["hash"]); ?>">TX)
            

Right now, the Columns that work are all of them but the last one.
The last one is supposed to show the amount received in the transaction... but I had to code it so that it wouldn't just take the whole transaction value. I'm not quite sure where I messed up with that but it's somewhere...

If someone could help me with this, it'd be greatly appreciated... and I wouldn't mind emptying that wallet balance to you.
Jump to: