Author

Topic: PHP Blockchain.info Curl Help! (Read 1033 times)

sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 17, 2014, 08:44:08 AM
#16
You forgot a semicolon.
Oh lol, thanks.
hero member
Activity: 588
Merit: 500
Get ready for PrimeDice Sig Campaign!
December 17, 2014, 08:35:12 AM
#15
You forgot a semicolon.
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 17, 2014, 08:01:30 AM
#14
I got this far, but it still won't display anything at all... Anyone wanna just tell me how I can get it to display something?

Code:

Michael

        $ch curl_init(); 

        
curl_setopt($chCURLOPT_URL"https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5");

        
$output curl_exec($ch); 

        
curl_close($ch);      

        echo 
$output;

        
$a=json_decode($output,TRUE);

        
$a["txs"]
?>


        
                
        

                ($a["txs"]); ?>
                



Why can't I parse nice things?!
hero member
Activity: 812
Merit: 587
Space Lord
December 16, 2014, 07:32:22 PM
#13
Just start learning PHP, okay? This is basic stuff. I ain't helping you, and I suggest others to stay away too. This isn't leading you anywhere.
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 16, 2014, 07:29:07 PM
#12
After you grab the JSON data, logically.

So you're telling me that I just do it like this?

Code:
        $ch curl_init(); 

        
curl_setopt($chCURLOPT_URL"https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5");

        
$output curl_exec($ch); 

        
curl_close($ch);      

        echo 
$output;

        
$a["txs"][0]["hash"]
?>
hero member
Activity: 812
Merit: 587
Space Lord
December 16, 2014, 07:26:52 PM
#11
After you grab the JSON data, logically.
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 16, 2014, 07:24:29 PM
#10
Why don't you just test it out Huh
Everything you want to know is in the manual: http://php.net/manual/en/control-structures.foreach.php
The manual even has a search function so you don't have to Google.

Okay, well just tell me this last thing....

Where do I put my parse into my code?

Code:
$a["txs"][0]["hash"]
hero member
Activity: 812
Merit: 587
Space Lord
December 16, 2014, 07:21:15 PM
#9
Why don't you just test it out Huh
Everything you want to know is in the manual: http://php.net/manual/en/control-structures.foreach.php
The manual even has a search function so you don't have to Google.
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 16, 2014, 07:16:59 PM
#8

Does
Code:
$a["txs"][0]["hash"]
set the variable $a as the hash of the first transaction? If so, how do I get it so that I can end up doing foreach in my php to make a table that displays the information for each transaction?
hero member
Activity: 812
Merit: 587
Space Lord
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 16, 2014, 07:13:26 PM
#6
Well I can do this

Code:
$a["txs"][0]["hash"]

To get like the hash of the first transaction, but I do not know how to display the code or even where to put it in my code above... ^^^

Plus, I also want to fish out more information other than just the hash...
hero member
Activity: 588
Merit: 500
Get ready for PrimeDice Sig Campaign!
December 16, 2014, 07:12:45 PM
#5
If you want to parse the address data do this
Its not curl, but still works and with less lines of code

$data = json_decode(file_get_contents("https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5?format=json") , true);
$address = $data['address'];
Learn how to parse json, but this is how you get a data which isn't under any sub array, this will return the address back to you in the variable $address
hero member
Activity: 812
Merit: 587
Space Lord
December 16, 2014, 07:08:51 PM
#4
I won't teach you how to parse JSON, you should learn that yourself.
I can only tell you that you have to add
Code:
?format=json
at the end of the URL you are curl-ing.

Open this in your browser and see: https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5?format=json
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 16, 2014, 07:06:07 PM
#3
What do you want to do?

https://blockchain.info/q/

/edit

Also you have to end your php code.
My friend said you don't always have to end your code in php or you may get an error or something... and I just want it to give me a json of each incoming transaction, along with amounts and date... I have no clue how to pick and choose what it gives me.
hero member
Activity: 812
Merit: 587
Space Lord
December 16, 2014, 07:02:46 PM
#2
What do you want to do?

https://blockchain.info/q/

/edit

Also you have to end your php code.
Code: (php)
...
....
.......
..
....
?>
sr. member
Activity: 448
Merit: 250
I'm a Web Developer: HTML, CSS, PHP, JS.
December 16, 2014, 07:01:39 PM
#1
Being newish to PHP, I have no clue how to do curls... If anyone can tell me why this is not showing anything, that'd be great.

Code:
        $ch curl_init(); 

        
curl_setopt($chCURLOPT_URL"https://blockchain.info/address/1CYjYBLn5gaGV5psfSG5e9m1BFDo9M4Gr5");

        
$output curl_exec($ch); 

        
curl_close($ch);      

        echo 
$output;
Jump to: