thinkphp micro disk, time disk, micro trading platform api files, virtual currency K-line normal
thinkphp micro disk, time disk, micro trading platform API file, virtual currency K-line normal
********************************************************** ?php
namespace app\index\controller;
use think\Controller;
use think\Db;
class Api extends Controller
{
public function __construct()
{
parent::__construct();
$this->nowtime = time();
$minute = date(‘Y-m-d H:i’, $this->nowtime) . ‘:00’;
$this->minute = strtotime($minute);
// Specify customer profit or loss:
// Write customer ID in array(), e.g., if customer ID is 1027, write array(1027)
// For multiple customers, separate with English commas, e.g., array(1027,2018,3765)
// Note: must be English comma, Chinese comma will cause error
$this->user_win = array(); // Specify customer profit
$this->user_loss = array(); // Specify customer loss
// K-line database
$this->klinedata = db(‘klinedata’);
}
public function getdate()
{
// Product list
$pro = db(‘productinfo’)->where(‘isdelete’, 0)->select();
if (!isset($pro)) return false;
$nowtime = time();
$_rand = rand(1, 900) / 100000;
$thisdatas = array();
foreach ($pro as $k => $v) {
// Verify market closed
// $isopen = ChickIsOpen($v[‘pid’]);
// if ($isopen) {
// continue;
// }
// Tencent Securities
if ($v[‘procode’] == ‘btc’ || $v[‘procode’] == ‘ltc’ || $v[‘procode’] == ‘trx’ || $v[‘procode’] == ‘eth’ || $v[‘procode’] == ‘eos’) {
$minute = date(‘i’, $nowtime);
if ($minute >= 0 && $minute < 15) {
$minute = 0;
} elseif ($minute >= 15 && $minute < 30) {
$minute = 15;
} elseif ($minute >= 30 && $minute < 45) {
$minute = 30;
} elseif ($minute >= 45 && $minute < 60) {
$minute = 45;
}
$new_date = strtotime(date(‘Y-m-d H’, $nowtime) . ‘:’ . $minute . ‘:00’);
if ($v[‘procode’] == ‘btc’) {
$url = ‘http://api.bitkk.com/data/v1/ticker?market=btc_usdt’;
} elseif ($v[‘procode’] == ‘ltc’) {
$url = ‘http://api.bitkk.com/data/v1/ticker?market=ltc_usdt’;
} elseif ($v[‘procode’] == ‘eth’) {
$url = ‘http://api.bitkk.com/data/v1/ticker?market=eth_usdt’;
} elseif ($v[‘procode’] == ‘eos’) {
$url = ‘http://api.bitkk.com/data/v1/ticker?market=eos_usdt’;
} elseif ($v[‘procode’] == ‘trx’) {
$url = ‘http://api.bitkk.com/data/v1/ticker?market=trx_usdt’;
}
$getdata = $this->curlfun($url);
$res = json_decode($getdata, 1);
$data_arr = $res[‘ticker’];
// var_dump($res[‘ticker’]);
// exit;
// $getdata = substr($getdata,2,-2);
// $data_arr = explode(‘:’,$getdata);
if (!is_array($data_arr)) continue;
// $Price = explode(‘,’,$data_arr[10]);
// $Open = explode(‘,’,$data_arr[7]);
// $Close = explode(‘,’,$data_arr[7]);
// $High = explode(‘,’,$data_arr[3]);
// $Low = explode(‘,’,$data_arr[7]);
$thisdata[‘Price’] = $this->fengkong($data_arr[‘sell’], $v);
$thisdata[‘Open’] = $data_arr[‘buy’];
$thisdata[‘Close’] = $data_arr[‘last’];
$thisdata[‘High’] = $data_arr[‘high’];
$thisdata[‘Low’] = $data_arr[‘low’];
$thisdata[‘Diff’] = 0;
$thisdata[‘DiffRate’] = 0;
$thisdata[‘Name’] = $v[‘ptitle’];
} elseif (in_array($v[‘procode’], array(12, 13, 116))) {
// Pocket Precious Metals
$url = ‘https://m.sojex.net/api.do?rtp=GetQuotesDetail&id=’ . $v[‘procode’];
// $html = file_get_contents($url);
$html = $this->curlfun($url);
$res = json_decode($html, 1);
$res = $res[‘data’][‘quotes’];
// $thisdata[‘Price’] = $this->fengkong($res[‘buy’],$v);;
$thisdata[‘Price’] = $res[‘buy’];
$thisdata[‘Open’] = $res[‘open’];
$thisdata[‘Close’] = $res[‘last_close’];
$thisdata[‘High’] = $res[‘top’];
$thisdata[‘Low’] = $res[‘low’];
$thisdata[‘Diff’] = 0;
$thisdata[‘DiffRate’] = 0;
} elseif (in_array($v[‘procode’], array(‘llg’, ‘lls’))) {
$url = ‘https://www.91pme.com/marketdata/gethq?code=’ . $v[‘procode’];
$html = $this->curlfun($url);
$arr = json_decode($html, 1);
if (!isset($arr[0])) continue;
$data_arr = $arr[0];
$thisdata[‘Price’] = $th
-
Alipay QR Code Scan
-
WeChat Scan Pay