Bitcoin Forum
December 04, 2016, 04:27:43 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Perl CGI script for displaying dynamic BTC price images based on mtgox rate  (Read 6144 times)
Bogart
Hero Member
*****
Offline Offline

Activity: 868


View Profile
April 24, 2011, 04:31:12 AM
 #1

# What: This CGI script will:
#   * Accept a single parameter: 'usd_value'.
#   * Fetch the current exchange rate for USD vs BTC from mtgox.
#   * Calculate an amount of BTC to equal the value of the USD input.
#   * Return that value, rendered as a PNG image, normalized to 2 decimal places.
#
# Why:   Some people would like to advetrise goods for sale online and accept BTC as payment, yet want to base their pricing on USD currency.
#      To continually update BTC prices as the rate of exchange varies can be a chore.
#      With this script hosted on a web server, an advertiser can embed a reference to the script URL as an image, with their USD price target as a parameter.
#      A PNG image showing the appropriate value will be dynamically generated for each viewer, based on the current mtgox exchange rate.

I hope this is useful.

I would host it myself for people to use, but I'm having some trouble with my web host, and have been unable to install libgd onto it.

To use the script, you will need to have the perl modules CGI, LWP, JSON, and GD installed.  You will also need to have libgd installed.

Install libgd first.  I was able to install it on Ubuntu 10.04 using:

sudo apt-get install libgd2-xpm-dev

Then install the perl modules:

sudo perl -MCPAN -e 'install CGI, LWP, JSON, GD'

It will probably want to install some other modules that these depend on.

Here is the script:
http://www.illumina23.com/usd2btc/1.0/usd2btc.pl

If the script fails to execute giving 500 Internal Server Error, try executing it from the shell and see if you receive an error message:

$ ./usd2btc.pl

"All safe deposit boxes in banks or financial institutions have been sealed... and may only be opened in the presence of an agent of the I.R.S." - President F.D. Roosevelt, 1933
1480868863
Hero Member
*
Offline Offline

Posts: 1480868863

View Profile Personal Message (Offline)

Ignore
1480868863
Reply with quote  #2

1480868863
Report to moderator
1480868863
Hero Member
*
Offline Offline

Posts: 1480868863

View Profile Personal Message (Offline)

Ignore
1480868863
Reply with quote  #2

1480868863
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480868863
Hero Member
*
Offline Offline

Posts: 1480868863

View Profile Personal Message (Offline)

Ignore
1480868863
Reply with quote  #2

1480868863
Report to moderator
1480868863
Hero Member
*
Offline Offline

Posts: 1480868863

View Profile Personal Message (Offline)

Ignore
1480868863
Reply with quote  #2

1480868863
Report to moderator
Cablesaurus
Sr. Member
****
Offline Offline

Activity: 302



View Profile WWW
April 25, 2011, 05:18:36 AM
 #2

Bump for great justice.
This would be very useful. Someone have a box under which this can be installed?

Edit: Now hosted @ http://www.cablesaurus.com/cgi-bin/usd2btc.cgi?usd_value=1 for the community's use. Thanks to Bogart for writing this! Credit goes to them.

PCIe Extender Cables; Dummy Plugs, Fans; PSU Cables; Cases & More
Visit www.Cablesaurus.com and our forum thread at http://bitcointalk.org/index.php?topic=6128.0
bitjet
Hero Member
*****
Offline Offline

Activity: 556


View Profile
June 14, 2011, 06:34:18 AM
 #3

Is anyone else hosting this?  Perhaps a conversion based on the 24hour?
oxxx
Member
**
Offline Offline

Activity: 82

in coin we trust


View Profile WWW
March 13, 2014, 08:42:58 PM
 #4

php+js, no-png, no-gox, btc-e, bitstamp, huobi, euro, usd, cny, rur - http://btc-price.org

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!