Author

Topic: Blockchain.info JSON Parsing help... (Read 1245 times)

hero member
Activity: 546
Merit: 500
December 21, 2014, 07:40:32 AM
#5
You can parse it like that:

Code:

   foreach ($tx["out"] as $out){
echo $out["addr"].""; }?>


legendary
Activity: 2912
Merit: 1060
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 17, 2014, 08:17:09 PM
#3
The JSON includes, for each txn, an array "prev_out" in "inputs". If no output in prev_out contains the address in question, it is inbound to the address. You could also use the filter field:

Code:
https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5?filter=2&format=json

The filters that I know of are:
  • 0-all
  • 1-sent
  • 2-received
  • 5-confirmed
  • 6-unspendable(default)
  • 7-unconfirmed
I have no idea what 3 and 4 are.

Awh, sweet dude... you sir are a lifesaver!
Code:
($tx["0"]["addr"]); ?>
is that how I print the sending address? I'm kinda new to parsing.
sr. member
Activity: 392
Merit: 259
Tips welcomed: 1CF4GhXX1RhCaGzWztgE1YZZUcSpoqTbsJ
December 17, 2014, 08:12:49 PM
#2
The JSON includes, for each txn, an array "prev_out" in "inputs". If no output in prev_out contains the address in question, it is inbound to the address. You could also use the filter field:

Code:
https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5?filter=2&format=json

The filters that I know of are:
  • 0-all
  • 1-sent
  • 2-received
  • 5-confirmed
  • 6-unspendable(default)
  • 7-unconfirmed
I have no idea what 3 and 4 are, except that they appear to be mutually exclusive. I can't find any txns that match filter 3.

If this helped, feel free to send what you feel is fair to 1EYhYbBKRSM85EaoUbgQmnCwQerQWL99so.
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 17, 2014, 07:37:57 PM
#1
I am trying to select only incoming transactions with my json parsing... how can I do that?
https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5?format=json

I also need help with changing the JSON Timestamp into a Day/Month/Year format...

Here is my code so far:
Code:

Michael

        $ch curl_init(); 

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

        
$output curl_exec($ch); 

        
curl_close($ch);      

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


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

            
            
        
    ?>
?>

            Date Received
        

            Received
        

                ($tx["time"]); ?>
            

                BTC(($tx["hash"]); ?>">TX)
            


Jump to: