Commit bba41db2 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

找币行情 See merge request !132
parents fd6cfca8 84c07ea5
......@@ -14,7 +14,8 @@ class Zhaobi extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_zhaobi';
protected $quotation_prefix = 'quotation_zhaobi_';
protected $base_url = 'https://api.biqianbao.top/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi';
protected $base_url = 'https://api.biqianbao.top';
#protected $base_url = 'https://api.biqianbao.top/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi';
public function symbolExists($tag = 'SFT', $aim = "CNY")
{
......@@ -33,7 +34,7 @@ class Zhaobi extends Exchange implements ExchangeInterface
*/
public function formatSymbol($tag = 'SFT', $aim = 'CNY')
{
return strtoupper($tag .'_'. $aim);
return strtolower(trim($tag) . trim($aim));
}
/**
......@@ -54,12 +55,27 @@ class Zhaobi extends Exchange implements ExchangeInterface
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
$api = $this->base_url . '/api/data/Ticker?sort=cname';
$content = $curl->get($api, false);
if (isset($content['message']) && 'OK' == $content['message']) {
$ticker_temp = [];
foreach ($content['data'] as $val) {
$ticker_temp = array_merge($ticker_temp, $val);
}
foreach ($ticker_temp as $val) {
$key = $this->quotation_prefix . strtolower($val['symbol']);
$this->redis->hmset($key, 'low', $val['low'], 'high', $val['high'], 'last', $val['last'], 'open', $val['open'], 'vol', $val['vol']);
$this->redis->sadd($this->supported_symbol, $val['symbol']);
}
}
$api = $this->base_url . '/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi';
$content = $curl->get($api, false);
if (is_array($content) && isset($content['code']) && (200 == $content['code'])) {
$data = $content['data'][0];
$key = $this->quotation_prefix . 'SFT_CNY';
$key = $this->quotation_prefix . 'sftcny';
$this->redis->hmset($key, 'low', $data['value'], 'high', $data['value'], 'last', $data['value']);
$this->redis->sadd($this->supported_symbol, 'SFT_CNY');
$this->redis->sadd($this->supported_symbol, 'SFTCNY');
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment