Author

Topic: [CLOSED] BOUNTY: 10 BTC for a simple script (Read 1230 times)

donator
Activity: 308
Merit: 250
December 23, 2011, 02:38:13 PM
#5
Code:
$decimals 2;

$ticker json_decode(file_get_contents('http://drayah.no.de/metals/latest'), TRUE);
$silver $ticker['silver']['quote'];

echo 
round($silver/31.1034768$decimals);
?>

drayah's node.js box parses the prices from kitco.com.

Update: Here's a version that fallbacks to http://services.packetizer.com/spotprices/ if drayah's service is down (I'm keeping the old one for posterity):
Code:
$decimals 2;

$drayah json_decode(file_get_contents('http://drayah.no.de/metals/latest'), TRUE);
if (
$drayah['silver']['quote'] > 0) {
$silver $drayah['silver']['quote'];
} else {
$packetizer = new SimpleXMLElement(file_get_contents('http://services.packetizer.com/spotprices/?f=xml'));
$silver $packetizer->silver;
}

echo 
round($silver/31.1034768$decimals);
?>
Update 2: Made another change should drayah's service be up but kitco down.
legendary
Activity: 2058
Merit: 1462
December 23, 2011, 02:25:04 PM
#4
more info please:

what scripting language?
which site to get the info from?
hero member
Activity: 504
Merit: 500
December 23, 2011, 02:14:56 PM
#3
Do you have your own feed source for the data?
legendary
Activity: 1386
Merit: 1002
December 23, 2011, 08:17:20 AM
#2
php?
hero member
Activity: 836
Merit: 1007
"How do you eat an elephant? One bit at a time..."
December 23, 2011, 07:57:10 AM
#1
Greetings Coders,

I am looking for a simple script that will do the following:

Display the price of 1 gram of silver in U.S. dollars

Additional info:

The spot price of silver is usually quoted in troy ounces on sites like www.kitco.com. Here is the conversion formula:

1 troy ounce = 31.1034768 grams

Please PM me if you are interested.

Thanks,
Trader Steve
Jump to: