Bitcoin Forum

Economy => Service Discussion => Topic started by: WebCanvas.in on December 04, 2013, 10:55:05 AM



Title: Mtgox rate in my webpage?
Post by: WebCanvas.in on December 04, 2013, 10:55:05 AM
How can I show the mtgox value on my webpage?
Any coding? or a simple script?

thank you.


Title: Re: Mtgox rate in my webpage?
Post by: MA5H3D on December 04, 2013, 11:07:00 AM
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.


Title: Re: Mtgox rate in my webpage?
Post by: WebCanvas.in on December 04, 2013, 11:13:35 AM
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