总发行量<\/div>
(.*?)<\/div>/is';
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
$result['circulate_count'] = $matches[0][1];
$result['publish_count'] = $matches[0][2];
$result = array_map(function ($value) {
return trim($value);
}, $result);
Yii::$app->cache->set($key, $result, 60);//set cache
return $result;
} catch (\Exception $exception) {
return new \stdClass();
}
}
return $result;
}
/**
* 快速修复方法,之后再改
*/
public static function quotationBTY()
{
$result = [
'price' => '',//价格
'dollar' => '',//价格美元
'btc' => '',//价格btc
'high' => '',//最高价
'low' => '',//最低价
'change' => '',//涨幅(跌幅)
'rank' => '',//流通市值排名
'circulate_value_rmb' => '',//流通市值人民币
'circulate_value_usd' => '',//流通市值美元
'circulate_value_btc' => '',//流通市值btc
'publish_count' => '',//发行总量
'circulate_count' => '',//流通总量
];
$ch = curl_init('https://kdata.zhaobi.com:4062/kdata?datafile=db&c=BTYUSDT&p=H1&action=init&count=24&ind=volumes&out=json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$content = curl_exec($ch);
$content = json_decode($content, true);
$content = $content['main']['y'];
$min = 10e9;
$max = 0;
foreach ($content as $item) {
for ($i = 0; $i < 4; $i++) {
$min = min($min, $item[$i]);
$max = max($max, $item[$i]);
}
}
$change = ($content[23][3] - $content[0][0]) / $content[0][0] * 100;
$result['dollar'] = $content[23][3];
$result['low'] = $min;
$result['high'] = $max;
$result['change'] = sprintf("%0.2f%%", $change);
return $result;
}
}