I think it'd be cool if we could get a DRK/BTC or DRK/$CURRENCY quote on this forum. I'm thinking maybe something underneath the user bar and above the path bar. Bonus points for a drop down for other currencies.
<?php
$cryptsyResponse = file_get_contents('http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=155');
$decoded = json_decode($cryptsyResponse);
$cryptsyPrice = (double)$decoded->return->markets->DRK->lasttradeprice;
$poloniexResponse = file_get_contents('https://poloniex.com/public?command=returnTicker');
$temp = json_decode($poloniexResponse, true);
$poloniexPrice = (double)$temp['BTC_DRK'];
if (empty($poloniexPrice))
{
$priceInBTC = floatval($cryptsyPrice);
}
if (empty($cryptsyPrice))
{
$priceInBTC = floatval($poloniexPrice);
}
if (!empty($poloniexPrice) && !empty($cryptsyPrice))
{
$priceInBTC = (floatval($poloniexPrice) + floatval($cryptsyPrice)) / 2;
}
echo "BTC/DRK " . $priceInBTC;
$amount = urlencode(100);
$from_Currency = urlencode(USD);
$to_Currency = urlencode(GBP);
$get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
$get = explode("<span class=bld>",$get);
$get = explode("</span>",$get[1]);
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);
$BTCeTicker = file_get_contents('https://btc-e.com/api/2/btc_usd/ticker');
$BTCeDecoded = json_decode($BTCeTicker);
$BTCePrice = (double)$BTCeDecoded->ticker->avg;
$bitstampTicker = file_get_contents('https://www.bitstamp.net/api/ticker');
$bitstampDecoded = json_decode($bitstampTicker, true);
$bitstampPrice = (double)$bitstampDecoded['last'];
$bitcoinPrice = (floatval($bitstampPrice) + floatval($BTCePrice)) / 2;
$priceDRKUSD = $priceInBTC * $bitcoinPrice;
echo "<br>";
echo "USD/DRK " . $priceDRKUSD;
?>
Very cool idea, thanks LZeppelin, funny my son's new fascination is the Hindenburg, LOL (Yes I know the band )
I sent you a dark, it's not much but I don't have much Let us know if we can use this on other sites. I'm planning on selling my husband's short stories for DarkCoin just to get attention for a novel he wrote. But it's not finished yet It'd be nice to have this on the site though
You must not have your darksend beta up and running, LOL. It didn't send, so I did it again. Hope you get it
<?php
include('top-cache.php');
$cryptsyResponse = file_get_contents('http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=155');
$decoded = json_decode($cryptsyResponse);
$cryptsyPrice = (double)$decoded->return->markets->DRK->lasttradeprice;
$poloniexResponse = file_get_contents('https://poloniex.com/public?command=returnTicker');
$temp = json_decode($poloniexResponse, true);
$poloniexPrice = (double)$temp['BTC_DRK'];
if (empty($poloniexPrice))
{
$priceInBTC = floatval($cryptsyPrice);
}
if (empty($cryptsyPrice))
{
$priceInBTC = floatval($poloniexPrice);
}
if (!empty($poloniexPrice) && !empty($cryptsyPrice))
{
$priceInBTC = (floatval($poloniexPrice) + floatval($cryptsyPrice)) / 2;
}
echo "BTC/DRK " . $priceInBTC;
$amount = urlencode(100);
$from_Currency = urlencode(USD);
$to_Currency = urlencode(GBP);
$get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
$get = explode("<span class=bld>",$get);
$get = explode("</span>",$get[1]);
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);
$BTCeTicker = file_get_contents('https://btc-e.com/api/2/btc_usd/ticker');
$BTCeDecoded = json_decode($BTCeTicker);
$BTCePrice = (double)$BTCeDecoded->ticker->avg;
$bitstampTicker = file_get_contents('https://www.bitstamp.net/api/ticker');
$bitstampDecoded = json_decode($bitstampTicker, true);
$bitstampPrice = (double)$bitstampDecoded['last'];
if (empty($bitstampPrice))
{
$bitcoinPrice = floatval($BTCePrice);
}
if (empty($BTCePrice))
{
$bitcoinPrice = floatval($bitstampPrice);
}
if (!empty($BTCePrice) && !empty($bitstampPrice))
{
$bitcoinPrice = (floatval($bitstampPrice) + floatval($BTCePrice)) / 2;
}
$priceDRKUSD = $priceInBTC * $bitcoinPrice;
echo "<br>";
echo "USD/DRK " . $priceDRKUSD;
include('bottom-cache.php');
?>
<?php
$url = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $url);
$file = $break[count($break) - 1];
$cachefile = 'cached-'.substr_replace($file ,"",-4).'.html';
$cachetime = 90;
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
echo "<!-- Cached copy, generated ".date('H:i', filemtime($cachefile))." -->\n";
include($cachefile);
exit;
}
ob_start(); // Start the output buffer
?>
<?php
// Cache the contents to a file
$cached = fopen("$cachefile", 'w');
fwrite($cached, ob_get_contents());
fclose($cached);
ob_end_flush(); // Send the output to the browser
?>
+1I think it'd be cool if we could get a DRK/BTC or DRK/$CURRENCY quote on this forum. I'm thinking maybe something underneath the user bar and above the path bar. Bonus points for a drop down for other currencies.
<!DOCTYPE=HTML>
<HTML>
<body>
<h1>Concept Price Ticker from API</h1>
<p>Will incorporate into forums eventually...</p>
<?php
/* Below is the code to pull the darkcoin price from mintpal. */
$mintpal = file_get_contents('https://api.mintpal.com/v1/market/stats/DRK/BTC');
$mintpalDecode = json_decode($mintpal);
$drk2btc = (double)$mintpalDecode[0]->last_price;
/*Below is the code for Coinbase spot price. */
$spotCoinbase = file_get_contents('https://coinbase.com/api/v1/prices/spot_rate');
$spotDecoded = json_decode($spotCoinbase);
$btcUSD = (double)$spotDecoded->{'amount'};
/*Below is the code for retreving a usd amount for Darkcoin and knocking
off decimal places for easy readability. */
$darkUSD = round(($btcUSD * $drk2btc), 2);
/*Below is printing out the data in a human readable format. */
echo "Current Bitcoin Price $" . $btcUSD, "<br>";
echo "Current Darkcoin Price $" . $darkUSD, "<br>";
echo "Current DRK/BTC " . $drk2btc, "<br>";
/*Below is when it was last updated */
echo "<br>";
echo "Updated at " . date('g:ia M d, Y') ."\n";
?>
</body>
</HTML>