Bitcoin Forum
May 30, 2024, 11:38:23 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Price Conversion Scripts for Websites.  (Read 575 times)
CorvusCorax (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 0



View Profile WWW
April 07, 2013, 07:22:46 PM
Last edit: April 08, 2013, 11:37:23 PM by CorvusCorax
 #1

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
Stampbit
Full Member
***
Offline Offline

Activity: 182
Merit: 100



View Profile
April 07, 2013, 08:05:49 PM
 #2

I'd like to know this as well, it could be very helpful for businesses.
CorvusCorax (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 0



View Profile WWW
April 09, 2013, 04:50:38 AM
 #3

Anything at all?
DarkPunk
Member
**
Offline Offline

Activity: 182
Merit: 10



View Profile
April 09, 2013, 04:58:07 AM
 #4

Sure... Would you like it in PHP, JS, or jQuery?  I'll whip one up for you, it's not really that hard.
ToasterLint
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
April 09, 2013, 05:01:31 AM
 #5

What is your site primarily programmed in?
Stampbit
Full Member
***
Offline Offline

Activity: 182
Merit: 100



View Profile
April 09, 2013, 05:03:53 AM
 #6

jquery is the standard, could you do this using mtgox 24hr avg?
DarkPunk
Member
**
Offline Offline

Activity: 182
Merit: 10



View Profile
April 09, 2013, 05:13:03 AM
 #7

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

Activity: 182
Merit: 10



View Profile
April 09, 2013, 05:22:45 AM
 #8

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
Stampbit
Full Member
***
Offline Offline

Activity: 182
Merit: 100



View Profile
April 09, 2013, 06:05:24 AM
Last edit: April 09, 2013, 02:19:49 PM by Stampbit
 #9

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
CorvusCorax (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 0



View Profile WWW
April 09, 2013, 04:18:45 PM
 #10

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.
CorvusCorax (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 0



View Profile WWW
April 09, 2013, 07:22:02 PM
 #11

Okay, I found something pretty close to what I was after at http://btcticker.appspot.com/. Cheers!
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!