Bitcoin Forum
November 09, 2024, 06:59:51 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Working with data sources for Bitcoin exchanges  (Read 1143 times)
salfter (OP)
Hero Member
*****
Offline Offline

Activity: 651
Merit: 501


My PGP Key: 92C7689C


View Profile WWW
December 11, 2012, 06:25:45 AM
 #1

I was knocking together a page of links today to use as a homepage on my computers, as part of migrating back to Firefox from Chrome. One thing I thought would be useful in this page would be a readout of the current MtGox ask price.  There are two sources I know of that I could pull in with an XMLHttpRequest:


Ideally, something that returned the "sell" item from the MtGox source as plain text would do what I want. Is such a source already out there, or should I try again to get it myself? I've used PHP to parse JSON, but not JavaScript, and eval() and JSON.Parse() (or whatever it's called) each had their problems working with the data I received from MtGox.

Beyond this somewhat immediate need, perhaps this thread would be useful for gathering info on what other data sources are already available.

Tipjars: BTC 1TipsGocnz2N5qgAm9f7JLrsMqkb3oXe2 LTC LTipsVC7XaFy9M6Zaf1aGGe8w8xVUeWFvR | My Bitcoin Note Generator | Pool Auto-Switchers: zpool MiningPoolHub NiceHash
Bitgem Resources: Pool Explorer Paper Wallet
bitcoin02
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
December 11, 2012, 07:25:49 PM
 #2

btcticker.appspot.com
salfter (OP)
Hero Member
*****
Offline Offline

Activity: 651
Merit: 501


My PGP Key: 92C7689C


View Profile WWW
December 11, 2012, 10:45:54 PM
 #3

btcticker.appspot.com

Interesting...it pulls the information I'd want to use, but it only appears to offer to return the result as text rendered into a PNG.

I've been trying to wrap my head around handling JSON data inside JavaScript.  You'd think this would be easy, but most browsers throw up a roadblock to keep a page from accessing JSON data from other sources.  While this fends off a potential source of XSS attacks, it makes working with data a bit of a pain.  Consider this, based on this demo:

Code:
<html>
<head>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://saltybeagle.com/cors/cors.js"></script>
</head>
<body onload="javascript:OnLoad();">
<div><span id="foo"></span></div>
<script type="text/javascript">
  function OnLoad()
  {
    getCORS("http://ucommbieber.unl.edu/CORS/cors.php", null, function(data) { document.getElementById("foo").innerHTML=data; });
  }
</script>
</body>
</html>

http://ucommbieber.unl.edu/CORS/cors.php returns a plaintext message when you send it a GET request.  getCORS() is supposed to use cross-origin resource sharing (CORS) to enable fetching data from remote sources.  When you point it at any of the blockchain.info API URLs (even plaintext ones like http://blockchain.info/q/hashrate), though, it fails to pull anything through.  I suspect there's something not implemented server-side.  JSONP fails pretty miserably, too. Is there any method to access JSON data on a remote site from JavaScript in a browser that doesn't rely on you running your own webserver or proxy and that doesn't rely on anything special being set up on the remote server?  Basically, it should be possible to write some HTML and JavaScript into a file and have a browser run it.  I'll be damned if I can figure it out, though.  I've done plenty of JSON manipulation with PHP, so it's not like I'm completely unfamiliar with it.

Tipjars: BTC 1TipsGocnz2N5qgAm9f7JLrsMqkb3oXe2 LTC LTipsVC7XaFy9M6Zaf1aGGe8w8xVUeWFvR | My Bitcoin Note Generator | Pool Auto-Switchers: zpool MiningPoolHub NiceHash
Bitgem Resources: Pool Explorer Paper Wallet
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!