Bitcoin Forum
November 13, 2024, 04:24:41 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Mtgox rate in my webpage?  (Read 623 times)
WebCanvas.in (OP)
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile WWW
December 04, 2013, 10:55:05 AM
 #1

How can I show the mtgox value on my webpage?
Any coding? or a simple script?

thank you.
MA5H3D
Member
**
Offline Offline

Activity: 99
Merit: 10


View Profile
December 04, 2013, 11:07:00 AM
 #2

There's probably a better way to do it, but you can do it like this:

Two pages, you can change the refresh interval in index.php

Page 1 = index.php -

<!DOCTYPE html>
<head>
      <title>Bitcoin Price</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
      <meta http-equiv="Pragma" content="no-cache">
      <meta http-equiv="Expires" content="0">

      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
      
      <script>
         var auto_refresh = setInterval(
         function()
         {$('.btc-price').load('gox.php');}, 10000);
      </script>
</head>

<body>
<div class="btc-price">Wait 10 Seconds..</div>
</body>

</html>


Page 2 = gox.php -

<?php
header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
header('Pragma: no-cache'); // HTTP 1.0.
header('Expires: 0'); // Proxies.

$data = file_get_contents("https://data.mtgox.com/api/2/BTCUSD/money/ticker_fast");
$data = json_decode($data, true);
$spot_last = $data['data']['last']['value'];
print_r($spot_last);
?>

Try That.
WebCanvas.in (OP)
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile WWW
December 04, 2013, 11:13:35 AM
 #3

Thanks a bunch. Will try that..

I guess there is a way to show btc-e rates too if I choose BTC and LTC price. Would be grateful if you help me with that.
Appreciated +1
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!