EDIT: Just realized that it is properly spaced/indented in the HTML source when viewing the page, so that helps a ton. Just posting that in case it helps someone else.
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
function mtgox_query($path, array $req = array()) {
// API settings
$key = '';
$secret = '';
// generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems
$mt = explode(' ', microtime());
$req['nonce'] = $mt[1].substr($mt[0], 2, 6);
// generate the POST data string
$post_data = http_build_query($req, '', '&');
// generate the extra headers
$headers = array(
'Rest-Key: '.$key,
'Rest-Sign: '.base64_encode(hash_hmac('sha512', $post_data, base64_decode($secret), true)),
);
// our curl handle (initialize if required)
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
}
curl_setopt($ch, CURLOPT_URL, 'https://mtgox.com/api/'.$path);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// run the query
$res = curl_exec($ch);
if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
$dec = json_decode($res, true);
if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists');
return $dec;
}
// example 1: get infos about the account, plus the list of rights we have access to
var_dump(mtgox_query('0/info.php'));
// old api (get funds)
var_dump(mtgox_query('0/getFunds.php'));
// trade example
// var_dump(mtgox_query('0/buyBTC.php', array('amount' => 1, 'price' => 15)));
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
array(8) { ["Login"]=> string(8) "MYLOGIN" ["Index"]=> string(4) "6532" ["Rights"]=> array(2) { [0]=> string(8) "get_info" [1]=> string(5) "trade" } ["Language"]=> string(5) "en_US" ["Created"]=> string(19) "2011-04-29 21:51:06" ["Last_Login"]=> string(19) "2012-02-12 06:23:55" ["Wallets"]=> array(2) { ["BTC"]=> array(5) { ["Balance"]=> array(4) { ["value"]=> string(10) "0.98988000" ["value_int"]=> string(8) "98988000" ["display"]=> string(15) "0.98988000Â BTC" ["currency"]=> string(3) "BTC" } ["Operations"]=> int(137) ["Daily_Withdraw_Limit"]=> array(4) { ["value"]=> string(12) "400.00000000" ["value_int"]=> string(11) "40000000000" ["display"]=> string(17) "400.00000000Â BTC" ["currency"]=> string(3) "BTC" } ["Monthly_Withdraw_Limit"]=> NULL ["Max_Withdraw"]=> array(4) { ["value"]=> string(12) "400.00000000" ["value_int"]=> string(11) "40000000000" ["display"]=> string(17) "400.00000000Â BTC" ["currency"]=> string(3) "BTC" } } ["USD"]=> array(5) { ["Balance"]=> array(4) { ["value"]=> string(7) "0.06833" ["value_int"]=> string(4) "6833" ["display"]=> string(8) "$0.06833" ["currency"]=> string(3) "USD" } ["Operations"]=> int(167) ["Daily_Withdraw_Limit"]=> array(4) { ["value"]=> string(10) "1000.00000" ["value_int"]=> string(9) "100000000" ["display"]=> string(12) "$1,000.00000" ["currency"]=> string(3) "USD" } ["Monthly_Withdraw_Limit"]=> array(4) { ["value"]=> string(11) "10000.00000" ["value_int"]=> string(10) "1000000000" ["display"]=> string(13) "$10,000.00000" ["currency"]=> string(3) "USD" } ["Max_Withdraw"]=> array(4) { ["value"]=> string(10) "1000.00000" ["value_int"]=> string(9) "100000000" ["display"]=> string(12) "$1,000.00000" ["currency"]=> string(3) "USD" } } } ["Trade_Fee"]=> float(0.55) } array(2) { ["usds"]=> string(7) "0.06833" ["btcs"]=> string(7) "0.98988" }
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}