Bitcoin Forum
December 10, 2016, 10:54:28 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Obtain bitcoin value with javascript.  (Read 2481 times)
conbitcoin.com
Newbie
*
Offline Offline

Activity: 22


View Profile
June 25, 2011, 09:23:31 PM
 #1

Hi, i saw this script: http://sanescreen.org/converter/ for converting values.

But i dont know if it is going to be updated with the actual rates every 5 minutes in the following days.

Anyone know about some script to convert dollars to btc ? Or how can i obtain the mtgox value from https://mtgox.com/trade/history with javascript ?

Thanks alot !

Comprar, Vender e Intercambiar con bitcoins (http://conbitcoin.com)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
sakkaku
Member
**
Offline Offline

Activity: 70



View Profile WWW
June 25, 2011, 09:36:20 PM
 #2

If you are fetching the values for use in purchases, etc you don't want to do it with javascript.  Also it is somewhat of a rude thing to do if your site grows large because every customer coming to your site will hit the other site with a request.  Even if you somehow cache on the client side it will still be x number of pageviews per hour nailing the 3rd party.

13NiQcetcioQj3YwHL1ZWvgQg8eAjkzUdt
Blog/Projects: zxlu.com | syn-multiminer
conbitcoin.com
Newbie
*
Offline Offline

Activity: 22


View Profile
June 25, 2011, 10:28:46 PM
 #3

I can do it with php caching the result but i dont know how to extract the value from mtgox because it is loaded with javascript.

"<div id="ticker">Sorry, you must have Javascript enabled to use Mt. Gox</div>"

Some tip or web where i can obtain the bitcoin value ?

Thanks alot !

Comprar, Vender e Intercambiar con bitcoins (http://conbitcoin.com)
riush
Member
**
Offline Offline

Activity: 73


View Profile
June 26, 2011, 05:31:43 AM
 #4

not sure what they're planning to do with it but it seems the ticker api is returning data..
https://mtgox.com/code/data/ticker.php

or, you could use the bitcoincharts api http://bitcoincharts.com/about/markets-api/

1MKKiJhUJgqKyfCLeo7bB1bvELNEM8wUbz
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
June 26, 2011, 04:11:37 PM
 #5

Hello people's.

You don't want to get the value each time a page is loaded. What you want to do is get the value every hour or every day or something like that, and save it to a database or file. The way I achieved this was to create a PHP script which extracts the ticker info from Mt. Gox and saves it to a file and/or into a database. Next I used Cron Jobs to make the script run automatically every two hours.

I will write a thread that describes how to do this (and provide the project code). BUT FIRST I need a little bit of help. My script was running smoothly until after the Mt. Gox crash. Now that Mt. Gox is back online my script still doesn't seem to be working. I checked the Mt. Gox ticker file manually and it seemed to be providing the json data as it should.

So that led me to believe maybe they were filtering out some of the headers. I was initially using the simple file_get_contents() function to retrieve the ticker data, so I decided to try the cURL functions and modify the header information to spoof my user agent. But that didn't seem to work either. Any help will be appreciated!  Grin

EDIT: Do not worry peoples, I have figured it out! I am writing up a thread on this now. I hope people will find it useful.

EDIT: Here you go: http://forum.bitcoin.org/index.php?topic=22886.0

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
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!