Bitcoin Forum
December 06, 2016, 10:27:30 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Displaying active bitcoin stats on my webpage  (Read 868 times)
Houseonfire
Full Member
***
Offline Offline

Activity: 129


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.
1481020050
Hero Member
*
Offline Offline

Posts: 1481020050

View Profile Personal Message (Offline)

Ignore
1481020050
Reply with quote  #2

1481020050
Report to moderator
1481020050
Hero Member
*
Offline Offline

Posts: 1481020050

View Profile Personal Message (Offline)

Ignore
1481020050
Reply with quote  #2

1481020050
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481020050
Hero Member
*
Offline Offline

Posts: 1481020050

View Profile Personal Message (Offline)

Ignore
1481020050
Reply with quote  #2

1481020050
Report to moderator
1481020050
Hero Member
*
Offline Offline

Posts: 1481020050

View Profile Personal Message (Offline)

Ignore
1481020050
Reply with quote  #2

1481020050
Report to moderator
1481020050
Hero Member
*
Offline Offline

Posts: 1481020050

View Profile Personal Message (Offline)

Ignore
1481020050
Reply with quote  #2

1481020050
Report to moderator
Houseonfire
Full Member
***
Offline Offline

Activity: 129


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



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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!