Bitcoin Forum
April 25, 2024, 05:31:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Displaying active bitcoin stats on my webpage  (Read 1021 times)
Houseonfire (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100


View Profile
November 28, 2011, 07:45:34 AM
 #1

I'm having a hard time figuring out how to display current mtgox stats on my web page.
I honestly have no idea where to start, and I can't find anything helpful online for how to do it.
The page I want to display on is my bithopper mining stats page, so its an html page.

I have the APIs from MtGox and tradehill but I don't know how to use them.
I HATE TABLES I HATE TABLES I HA(╯°□°)╯︵ ┻━┻ TABLES I HATE TABLES I HATE TABLES
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714023069
Hero Member
*
Offline Offline

Posts: 1714023069

View Profile Personal Message (Offline)

Ignore
1714023069
Reply with quote  #2

1714023069
Report to moderator
1714023069
Hero Member
*
Offline Offline

Posts: 1714023069

View Profile Personal Message (Offline)

Ignore
1714023069
Reply with quote  #2

1714023069
Report to moderator
1714023069
Hero Member
*
Offline Offline

Posts: 1714023069

View Profile Personal Message (Offline)

Ignore
1714023069
Reply with quote  #2

1714023069
Report to moderator
Houseonfire (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100


View Profile
November 30, 2011, 09:22:58 AM
 #2

Is there anyone willing to help? I just want it displayed on my own page that me and a few friends are using.. It's nothing commercial or anything. The BitHopper people aren't helping me any, so i'm looking to the community for help.

Thanks
phorensic
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
December 03, 2011, 04:32:18 AM
 #3

Here is how I did it on my old mining pool website with PHP and mySQL from TradeHill, which is *very* similar to how you would do it with MtGox, unless you want to use websocket/sockets.io for live AJAX stuff.

Code:
$file = fopen("https://api.tradehill.com/APIv1/USD/Ticker", "rb");
$tradedata = fread($file, 8192);
fclose($file);

$jsonTradedata = json_decode($tradedata, true);

mysql_query("UPDATE `websiteSettings` SET `tradeHillWorth` = '".$jsonTradedata['ticker']['last']."'");
echo $jsonTradedata['ticker']['last'];

This accessed a table in MySQL called websiteSettings in my main DB. You don't need a database, but it makes it easier to reduce load on your website because you can pool every N times, instead of every time the page loads.

Then you run this somewhere in your PHP code before you want to call the variable:

Code:
$tradeHillQ = mysql_query("SELECT `tradeHillWorth` FROM `websiteSettings`");
$tradeHillWorth = mysql_fetch_object($tradeHillQ);

Then you run this when you want to insert the price in the output of the HTML page:

Code:
<?php echo round($tradeHillWorth->tradeHillWorth2);?>

The code above will round it to two decimal places.  Again, this is very, very similar to how you would do it for any exchange.  Just read their API documentation.
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!