Bitcoin Forum
September 26, 2024, 05:56:34 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: .  (Read 760 times)
MicroGuy (OP)
Legendary
*
Offline Offline

Activity: 2506
Merit: 1030


Twitter @realmicroguy


View Profile WWW
April 19, 2013, 12:55:08 PM
Last edit: April 08, 2019, 05:35:32 PM by MicroGuy
 #1

.


Dougie
Full Member
***
Offline Offline

Activity: 211
Merit: 100


You are not special.


View Profile
April 19, 2013, 10:42:27 PM
 #2

It shouldn't be hard to implement if you have a bit of knowledge with PHP. Just use strip mtgox page. I'd use a cron task to save the price to a file to save requesting the page too much. The mtgox source code wouldn't be hard to strip with a simple regular expression finding "<li id="highPrice">High:<span>". You could even implement safety netting to stop it going below a certain cost in case mtgox gets hacked or the value drops for some reason.

Even simpler is using the blockchain API but then you have to trust blockchain. Very simple to pull:

https://blockchain.info/tobtc?currency=USD&value=10

These methods could be used to display the cost and if you have even more know how and patience at working out how the shopping cart works you could implement this into the cart.

Shouldn't be too hard. Don't let anyone charge you over the odds to implement it! (although you do want to make sure it's secure if you're giving the script access to your wallet!)

Lurking since 2011...
1J4DhU3q6RxxCTfAAcg5ExVK6FfxkmzkTH
relm9
Hero Member
*****
Offline Offline

Activity: 840
Merit: 1000



View Profile
April 19, 2013, 10:50:40 PM
 #3

Scraping the HTML code is really inefficient, Mt Gox has a JSON API:

http://data.mtgox.com/api/1/BTCUSD/ticker

Just decode the JSON and grab your desired value.
gglon
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
April 20, 2013, 08:51:24 AM
Last edit: April 20, 2013, 09:11:15 AM by gglon
 #4

Just decode the JSON and grab your desired value.

In short for last trade:

Code:
<?php
$url 
'http://data.mtgox.com/api/1/BTCUSD/ticker';
$json file_get_contents($url);
$obj json_decode($json);
print (
1.35*($obj->return->last_local->value));//last gox price times %
?>
If you want more stable price, use avg instead of last_local
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!