Post
Topic
Board Announcements (Altcoins)
Re: [ANN][LISK] Lisk | ICO | Decentralized Application & Sidechain Platform
by
nuno12345
on 05/03/2016, 07:05:38 UTC
For all price fanatics I have setup a simple price grabber that get's the ICO amout from ico.lisk.io and does the proper math to calculate the lisk price in satoshi and USD (bonus not included).



Does this image update itself?  Shocked

Okay, it does. Awesome API-magic. Could you please make the stuff public? Would like to change the formatting and design of this image.

P.S.: Why did the price fall from 2608 to 2584? Shouldn't it increase only?

If crypti price drops lisk value will drop, if btc drops lisk value will drop.

Here is the source code, all commented for easy understanding:

Code:
//http://simplehtmldom.sourceforge.net/
include_once('simple_html_dom.php');

//GET HTML FROM ICO.LISK.IO
$html file_get_html('https://ico.lisk.io/');

//GET CRYPTI AND BITCOIN PRICE
$priceXCR json_decode(file_get_contents("http://coinmarketcap-nexuist.rhcloud.com/api/xcr/price"), true)["btc"];
$priceBTC json_decode(file_get_contents("http://coinmarketcap-nexuist.rhcloud.com/api/btc/price"), true)["usd"];

//COUNTER TO KNOW WHICH COIN IS WHICH
$counter 0;

//SETUP PRICE VARS
$bitcoinICO 0;
$cryptiICO 0;

//LOOP THRU ALL SPANS IN ICO.LISK.IO
foreach($html->find('span') as $element
{
//FILTER FLOATS ONLY
$number preg_replace("/[^0-9\.]/"""$element);

if(is_numeric($number))
{
//0=BITCOIN AMOUNT, 1=CRYPTI AMOUNT, 2=SHAPESHIFT AMOUNT
if($counter==0$bitcoinICO += $number;
else if($counter==1$cryptiICO += $number;
else if($counter==2$bitcoinICO += $number;

//INCREASE COUNTER
$counter++;
}
}

//CONVERT CRYPTI AMOUNT TO BTC
$bitcoinICO+=($cryptiICO*$priceXCR);

//CALCULATE LISK PRICE AND CONVERT TO SATOSHI
$liskPriceBTC = ($bitcoinICO/85000000);
$liskPriceBTCRound round($liskPriceBTC*100000000);

//CONVERT LISK PRICE TO USD AND FORMAT TO 5 DECIMAL PLACES
$liskPriceUSD number_format((float)($liskPriceBTC*$priceBTC), 5'.''');

header("Content-Type: image/png");
//OPEN LISK LOGO
$im imageCreateFromPng("/var/www/html/lisk/lisk.png");
//DEAL WITH OPACITY
imageAlphaBlending($imtrue);
imageSaveAlpha($imtrue);

//SETUP TEXT COLOR
$text_color imagecolorallocate($im000);

//ADD TEXT TO LISK LOGO
imagestring($im312095,  "1 Lisk = " $liskPriceBTCRound " Satoshi"$text_color);
imagestring($im3120110,  "1 Lisk = " $liskPriceUSD " USD"$text_color);

//SAVE IMAGE
imagepng($im"/var/www/html/lisk/lisk_price.png");

//CLEAN BUFFER
imagedestroy($im);

?>

crontab -e
Code:
*/10 * * * * /usr/bin/php /var/www/html/lisk/index.php