Author

Topic: . (Read 768 times)

member
Activity: 64
Merit: 10
.
April 20, 2013, 03:51:24 AM
#4
Just decode the JSON and grab your desired value.

In short for last trade:

Code:
$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
hero member
Activity: 840
Merit: 1000
April 19, 2013, 05: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.
full member
Activity: 211
Merit: 100
You are not special.
April 19, 2013, 05: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 "
  • High:". 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!)
  • legendary
    Activity: 2506
    Merit: 1030
    Twitter @realmicroguy
    April 19, 2013, 07:55:08 AM
    #1
    .


    Jump to: