base_url . '/api/data/Ticker?sort=cname'; $res = $curl->get($api, false); $ticker = []; if (isset($res['message']) && 'OK' == $res['message']) { $this->code = 0; $ticker_temp = []; foreach ($res['data'] as $val) { $ticker_temp = array_merge($ticker_temp, $val); } foreach ($ticker_temp as $val) { foreach ($this->basic_coin as $k => $coin) { $explode_arr = explode($coin, $val['symbol']); if (2 == count($explode_arr) && empty($explode_arr[1])) { $temp = []; $temp['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin; $temp['currency'] = strtoupper($explode_arr[0]); $temp['base_currency'] = strtoupper($coin); $temp['close'] = (float)sprintf("%0.6f", $val['last']); $temp['close_usd'] = (float)sprintf("%0.6f", $val['last'] * $this->basic_price[$coin]['usd']); $temp['close_rmb'] = (float)sprintf("%0.4f", $val['last'] * $this->basic_price[$coin]['rmb']); $temp['change'] = (0 == $val['open']) ? 0 : (float)sprintf("%0.4f", ($val['last'] - $val['open']) / $val['open'] * 100); $temp['high_usd'] = (float)sprintf("%0.4f", $val['high'] * $this->basic_price[$coin]['usd']); $temp['low_usd'] = (float)sprintf("%0.4f", $val['low'] * $this->basic_price[$coin]['usd']); $temp['high_rmb'] = (float)sprintf("%0.4f", $val['high'] * $this->basic_price[$coin]['rmb']); $temp['low_rmb'] = (float)sprintf("%0.4f", $val['low'] * $this->basic_price[$coin]['rmb']); $temp['vol'] = (float)sprintf("%0.4f", $val['vol']); $temp['optional'] = false; $temp['platform_zh'] = '找币'; $temp['platform_us'] = 'zhaobi'; array_push($ticker, $temp); } } } } return ['code' => $this->code, 'ticker' => $ticker]; } public function getNotice($params = []) { $curl = new Curl(); if (isset($params['id']) && !empty($params['id'])) { $api = $this->base_url . '/api/data/noticedetail?id=' . $params['id']; $res = $curl->get($api, false); if (isset($res['message']) && 'OK' == $res['message']) { $this->code = 0; $res['data']['abstract'] = str_replace(' ', '', str_replace(' ', '', $res['data']['abstract'])); $res['data']['content'] = str_replace(' ', '', str_replace(' ', '', $res['data']['content'])); return ['code' => $this->code, 'notice' => $res['data']]; } else { return ['code' => $this->code, 'notice' => $res['data'], 'msg' => $res['message']]; } } $api = $this->base_url . '/api/data/noticelist?page=' . $params['page'] . '&size=' . $params['size']; $res = $curl->get($api, false); if (isset($res['message']) && 'OK' == $res['message']) { $this->code = 0; $notices = $res['data']['rows']; foreach ($notices as &$notice) { $notice['abstract'] = str_replace(' ', '', str_replace(' ', '', $notice['abstract'])); } $data = [ 'list' => $notices, 'count' => $res['data']['count'] ]; } return ['code' => $this->code, 'notice' => $data]; } }