Post
Topic
Board Services
Re: Quick PHP dev to parse out networkhashpersec ABE
by
nzbmaster
on 29/05/2013, 00:31:40 UTC
Here's a super quick take on your request. Call via url with ?coin=ftc for example or change $defaultCoin to the coin you want the last hashrate for.

It's probably easier to ask the dev to include the data in the json output though...

Code:

$defaultCoin 
'cnc';

$cryptoCurrencies = array(
'ppc'=>'PPCoin',
'trc'=>'Terracoin',
'frc'=>'Freicoin',
'bbq'=>'BBQCoin',
'nvc'=>'Novacoin',
'ftc'=>'Feathercoin',
'bte'=>'Bytecoin',
'btb'=>'BitBar',
'cnc'=>'CHNCoin',
'jkc'=>'JKC',
'frk'=>'Franko',
'gld'=>'Goldcoin'
);

$baseUrl 'http://%s.cryptocoinexplorer.com/chain/%s/q/nethash/1/-1';

$coin = (isset($_GET['coin']) && array_key_exists($_GET['coin'], $cryptoCurrencies)) ? $_GET['coin'] : $defaultCoin;

$url sprintf($baseUrl$coin$cryptoCurrencies[$coin]);
$rawdata file_get_contents($url);
if (
$rawdata)
{
if (preg_match("/\n(?P[a-z,]+)\nSTART DATA\n(?P.*?)\n/i"$rawdata$matches))
{
$headers explode(','$matches['headers']);
$data explode(','$matches['data']);

$result array_combine($headers$data);

echo $result['netHashPerSecond'];

//print_r($result);
}
}

?>