Commit 3dfad114 authored by rlgy's avatar rlgy

z网api

parent 03e87e57
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-28
* Time: 上午10:08
*/
namespace common\service\exchange;
class Zb extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_zb';
protected $quotation_prefix = 'quotation_zb_';
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
return strtolower(trim($tag) . '_' . trim($aim));
}
public function setSupportedSymbol()
{
$api = "http://api.zb.com/data/v1/markets";
$rev = $this->ch->get($api, false);
if ($rev) {
$keys = array_keys($rev);
foreach ($keys as $key) {
$this->redis->sadd($this->supported_symbol, str_replace('_', '', $key));
}
}
}
public function setQuotation()
{
$api = 'http://api.zb.com/data/v1/allTicker';
$rev = $this->ch->get($api, false);
if ($rev) {
foreach ($rev as $key => $item) {
$this->redis->hmset($this->quotation_prefix . $key, 'low', $item['low'], 'high', $item['high'], 'last',
$item['last']);
}
}
}
}
\ 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