Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Bobby on March 04, 2011, 12:14:03 AM



Title: HELP! Need to automate live bitcoin exchange rate.
Post by: Bobby on March 04, 2011, 12:14:03 AM
Basically I'm going to be selling certain items on my website such as Gold, Silver coins, etc.  I would like to accept bitcoin in payment but I need to be able to update the price in accordance to the bitcoin/USD exchange rate.  Since my website is written in PERL/CGI is there an easy way to obtain the latest exchange rate (current BID on MTGOX for example) and import it into a variable that I would use to update my prices in real time?  It's easy to look up manually but how would I write a script that would be able to look up the value?

Also would need to look up the spot price of Gold and Silver (in USD) at the same time.

There seem to be a lot of geniouses here so thanks in advance for any advice!

Bobby



Title: Re: HELP! Need to automate live bitcoin exchange rate.
Post by: Quip on March 04, 2011, 12:22:36 AM
No idea about perl, but in PHP:
Code:
$goxPrice = json_decode(file_get_contents("http://mtgox.com/code/data/ticker.php"))->{'ticker'}->{'sell'};
You can use "buy", "sell", or "last" based on your needs.


Title: Re: HELP! Need to automate live bitcoin exchange rate.
Post by: slush on March 04, 2011, 12:40:28 AM
Since my website is written in PERL/CGI

Try to search recent forum posts, yesterday somebody posted PERL code for parsing mtgox quotes...

Edit: Link to Perl module is on the wiki (https://en.bitcoin.it/wiki/MtGox). Nice job, mndrix!


Title: Re: HELP! Need to automate live bitcoin exchange rate.
Post by: Bobby on March 04, 2011, 12:56:08 AM
Exactly what I needed!  No longer BitCoin related but does anyone know a script that can fetch the spot price of Gold/Silver??

Thanks!