* @day: 2017/11/23 */ namespace crmeb\services; class HuobiService { const API_URL = 'https://sapi.ztpay.org/api/v2';//接口地址 private static $app_id = '84cef8cf-ghxertfvbf-13a8a0ca-997b0'; private static $app_secret = '739a0682-163aad52-b6c3ad63-40431'; /** * 实例化 * @return HuobiService */ public static function instance() { $instance = new self(); $instance::$app_id = sys_config('huobi_Access_Key', ''); $instance::$app_secret = sys_config('huobi_Secret_Key', ''); return $instance; } /** * 获取签名 * @param $data * @return string */ private static function getSign($data) { $signPars = ""; ksort($data); foreach ($data as $k => $v) { if ("sign" != $k && "" != $v && $v != "0") { $signPars .= $k . "=" . $v . "&"; } } $signPars .= "key=" . self::$app_secret; return strtoupper(md5($signPars)); } /** * 通用请求 * @param $data * @return bool|false|string */ private static function request($data) { $data['sign'] = self::getSign($data); return json_decode(do_request(self::API_URL, $data), true); } }