Bitcoin Forum

Other => Beginners & Help => Topic started by: CorvusCorax on April 07, 2013, 07:22:46 PM



Title: Price Conversion Scripts for Websites.
Post by: CorvusCorax on April 07, 2013, 07:22:46 PM
Hi, all!

I'm in the process of starting up a bitcoin-based business. Because what I'm offering (artwork) pretty much requires contact with the client in order to get the order and associated details correct, I'm not going to bother using a payment front-end such as Mt.Gox. The front-end they use, however, had a nice feature on it and that was to automatically convert the price from US$ to BTC based on the going exchange rate.

So my question is, does anyone with a head for scripting have or know of a script that I can put on my website, can set the US$ price and have it obtain and display the price in BTC at that moment, instead of requiring me to change my site daily (or more) to reflect the current price?

Thanks in advance!

CorvusCorax


Title: Re: Price Conversion Scripts for Websites.
Post by: Stampbit on April 07, 2013, 08:05:49 PM
I'd like to know this as well, it could be very helpful for businesses.


Title: Re: Price Conversion Scripts for Websites.
Post by: CorvusCorax on April 09, 2013, 04:50:38 AM
Anything at all?


Title: Re: Price Conversion Scripts for Websites.
Post by: DarkPunk on April 09, 2013, 04:58:07 AM
Sure... Would you like it in PHP, JS, or jQuery?  I'll whip one up for you, it's not really that hard.


Title: Re: Price Conversion Scripts for Websites.
Post by: ToasterLint on April 09, 2013, 05:01:31 AM
What is your site primarily programmed in?


Title: Re: Price Conversion Scripts for Websites.
Post by: Stampbit on April 09, 2013, 05:03:53 AM
jquery is the standard, could you do this using mtgox 24hr avg?


Title: Re: Price Conversion Scripts for Websites.
Post by: DarkPunk on April 09, 2013, 05:13:03 AM
jquery is the standard, could you do this using mtgox 24hr avg?

jQuery will still require a PHP-proxy script, because of modern cross-site security implementations.

Give me a few minutes, and I'll post a php script to fetch the MtGox Avg. and a jQuery script to catch it.


Title: Re: Price Conversion Scripts for Websites.
Post by: DarkPunk on April 09, 2013, 05:22:45 AM
PHP (mtgox_ticker.php)
Code:
<?php

echo json_encode(file_get_contents('https://data.mtgox.com/api/2/BTCUSD/money/ticker'));

?>


jQuery (ticker.js)
Code:
function getMtGoxTicker() {
 return jQuery.parseJSON($.ajax({
  dataType: "JSON",
  url: "mtgox_ticker.php",
  async: false
 }).responseText);
}

This should return a JavaScript object array with all the BTC price data your heart could want.

Data API: https://data.mtgox.com/api/2/BTCUSD/money/ticker


Title: Re: Price Conversion Scripts for Websites.
Post by: Stampbit on April 09, 2013, 06:05:24 AM
PHP (mtgox_ticker.php)
Code:
<?php

echo json_encode(file_get_contents('https://data.mtgox.com/api/2/BTCUSD/money/ticker'));

?>


jQuery (ticker.js)
Code:
function getMtGoxTicker() {
 return jQuery.parseJSON($.ajax({
  dataType: "JSON",
  url: "mtgox_ticker.php",
  async: false
 }).responseText);
}


This should return a JavaScript object array with all the BTC price data your heart could want.

Data API: https://data.mtgox.com/api/2/BTCUSD/money/ticker

awesome thanks


Title: Re: Price Conversion Scripts for Websites.
Post by: CorvusCorax on April 09, 2013, 04:18:45 PM
A ticker is great, but it's not quite what I was after. I was looking for something I could input a price into and it would come back with a price in BTC displayed on my website for the item I was selling based on the current exchange rate.

My site is a free website provider, so I'm not sure what it's programmed in, but it could be moved, or I have other servers that could do the heavy lifting in PHP or the like if queried.


Title: Re: Price Conversion Scripts for Websites.
Post by: CorvusCorax on April 09, 2013, 07:22:02 PM
Okay, I found something pretty close to what I was after at http://btcticker.appspot.com/. Cheers!