Bitcoin Forum
November 02, 2024, 01:38:51 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: PHP Blockchain.info Curl Help!  (Read 1054 times)
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 16, 2014, 11: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:
<?php 
        $ch 
curl_init(); 

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

        
$output curl_exec($ch); 

        
curl_close($ch);      

        echo 
$output;

Parazyd
Hero Member
*****
Offline Offline

Activity: 812
Merit: 587


Space Lord


View Profile WWW
December 16, 2014, 11: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)
<?php
...
....
.......
..
....
?>
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 16, 2014, 11: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.

Parazyd
Hero Member
*****
Offline Offline

Activity: 812
Merit: 587


Space Lord


View Profile WWW
December 16, 2014, 11: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
williamj2543
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500

Get ready for PrimeDice Sig Campaign!


View Profile WWW
December 16, 2014, 11: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

█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
▓▓▓▓▓  BIT-X.comvvvvvvvvvvvvvvi
→ CREATE ACCOUNT 
▓▓▓▓▓
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 16, 2014, 11: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...

Parazyd
Hero Member
*****
Offline Offline

Activity: 812
Merit: 587


Space Lord


View Profile WWW
December 16, 2014, 11:14:43 PM
 #7

http://php.net/manual/en/index.php
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 16, 2014, 11: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?

Parazyd
Hero Member
*****
Offline Offline

Activity: 812
Merit: 587


Space Lord


View Profile WWW
December 16, 2014, 11: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.
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 16, 2014, 11: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"]

Parazyd
Hero Member
*****
Offline Offline

Activity: 812
Merit: 587


Space Lord


View Profile WWW
December 16, 2014, 11:26:52 PM
 #11

After you grab the JSON data, logically.
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 16, 2014, 11:29:07 PM
 #12

After you grab the JSON data, logically.

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

Code:
<?php 
        $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"]
?>

Parazyd
Hero Member
*****
Offline Offline

Activity: 812
Merit: 587


Space Lord


View Profile WWW
December 16, 2014, 11: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.
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 17, 2014, 12:01:30 PM
Last edit: December 17, 2014, 12:12:13 PM by michaeladair
 #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:
<html>
<title>Michael</title>
<body>
<?php 
        $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"]
?>

<table>
        <tr>
                <td>
                <?php print_r($a["txs"]); ?>
                </td>
        </tr>
</table>
</body>
</html>

Why can't I parse nice things?!

williamj2543
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500

Get ready for PrimeDice Sig Campaign!


View Profile WWW
December 17, 2014, 12:35:12 PM
 #15

You forgot a semicolon.

█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
▓▓▓▓▓  BIT-X.comvvvvvvvvvvvvvvi
→ CREATE ACCOUNT 
▓▓▓▓▓
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
michaeladair (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


I'm a Web Developer: HTML, CSS, PHP, JS.


View Profile
December 17, 2014, 12:44:08 PM
 #16

You forgot a semicolon.
Oh lol, thanks.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!