Bitcoin Forum
May 05, 2024, 07:33:28 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Chart for website.  (Read 949 times)
QsoftStudios (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 0



View Profile WWW
November 09, 2013, 07:43:14 AM
 #1

Hello, I would like to put a chart on my website that shows the current BTC-e and Bitstamp BTC price. However I am not quite sure how to do this. I have a feeling it would be PHP parsing JSON from the exchanges but I'm not quite sure. Anyone know how to do this that could help? Smiley
1714894408
Hero Member
*
Offline Offline

Posts: 1714894408

View Profile Personal Message (Offline)

Ignore
1714894408
Reply with quote  #2

1714894408
Report to moderator
1714894408
Hero Member
*
Offline Offline

Posts: 1714894408

View Profile Personal Message (Offline)

Ignore
1714894408
Reply with quote  #2

1714894408
Report to moderator
The block chain is the main innovation of Bitcoin. It is the first distributed timestamping system.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
duxZero
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
November 09, 2013, 09:44:36 AM
 #2

Just use the API's for the big popular exchanges.

I can even give you a snippet that does this if need be.
QsoftStudios (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 0



View Profile WWW
November 09, 2013, 09:47:48 AM
 #3

Just use the API's for the big popular exchanges.

I can even give you a snippet that does this if need be.


That be awesome thank you! I need to learn more about how JSON and how the different APIs work lol.
duxZero
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
November 09, 2013, 10:08:05 AM
Last edit: November 09, 2013, 10:24:12 AM by duxZero
 #4

https://www.bitstamp.net/api/

https://btc-e.com/api/2/btc_usd/ticker

Code:
<?php

        
function getStats($e) {
            
$cookies tmpfile();
            
$userAgent 'duxZero';

            
$eURL NULL;

            switch (
$e) {
                case 
"btc-e":
                    
$eURL "https://btc-e.com/api/2/btc_usd/ticker";
                    break;
                case 
"bitstamp":
                    
$eURL "https://www.bitstamp.net/api/ticker/";
                    break;
                default:
                    
$eURL "https://www.bitstamp.net/api/ticker/";
                    break;
            }

            
$cURL curl_init($eURL);

            
$options = array(
                
CURLOPT_CONNECTTIMEOUT => 20,
                
CURLOPT_USERAGENT => $userAgent,
                
CURLOPT_AUTOREFERER => true,
                
CURLOPT_FOLLOWLOCATION => true,
                
CURLOPT_RETURNTRANSFER => true,
                
CURLOPT_COOKIEFILE => $cookies,
                
CURLOPT_COOKIEJAR => $cookies,
                
CURLOPT_SSL_VERIFYPEER => 0,
                
CURLOPT_SSL_VERIFYHOST => 0
            
);

            
curl_setopt_array($cURL$options);
            
$contents curl_exec($cURL);
            
curl_close($cURL);
            return 
json_decode($contentstrue);
        }

        
$a getStats("btc-e");
        echo 
$a['ticker']['high'];

        echo 
"<br/>";

        
$b getStats("bitstamp");
        echo 
$b['high'];
        
?>

QsoftStudios (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 0



View Profile WWW
November 09, 2013, 10:43:12 AM
 #5

https://www.bitstamp.net/api/

https://btc-e.com/api/2/btc_usd/ticker

Code:
<?php

        
function getStats($e) {
            
$cookies tmpfile();
            
$userAgent 'duxZero';

            
$eURL NULL;

            switch (
$e) {
                case 
"btc-e":
                    
$eURL "https://btc-e.com/api/2/btc_usd/ticker";
                    break;
                case 
"bitstamp":
                    
$eURL "https://www.bitstamp.net/api/ticker/";
                    break;
                default:
                    
$eURL "https://www.bitstamp.net/api/ticker/";
                    break;
            }

            
$cURL curl_init($eURL);

            
$options = array(
                
CURLOPT_CONNECTTIMEOUT => 20,
                
CURLOPT_USERAGENT => $userAgent,
                
CURLOPT_AUTOREFERER => true,
                
CURLOPT_FOLLOWLOCATION => true,
                
CURLOPT_RETURNTRANSFER => true,
                
CURLOPT_COOKIEFILE => $cookies,
                
CURLOPT_COOKIEJAR => $cookies,
                
CURLOPT_SSL_VERIFYPEER => 0,
                
CURLOPT_SSL_VERIFYHOST => 0
            
);

            
curl_setopt_array($cURL$options);
            
$contents curl_exec($cURL);
            
curl_close($cURL);
            return 
json_decode($contentstrue);
        }

        
$a getStats("btc-e");
        echo 
$a['ticker']['high'];

        echo 
"<br/>";

        
$b getStats("bitstamp");
        echo 
$b['high'];
        
?>


Thank you very much!
duxZero
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
November 09, 2013, 10:47:43 AM
 #6

Anytime, i made it easy to implement other exchanges in the future to.
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!