<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\SDK; use ModStart\Core\Input\Response; use ModStart\Core\Util\CurlUtil; use Module\Vendor\Log\Logger; class HttpRequest { protected $LOG_FILE = 'base_request'; protected $LOG_PREFIX = 'BaseRequest'; protected $BASE_URL = ''; protected $REQUEST_INTERVAL_US = 0; protected function info($o_2ro, $pwDm3) { Logger::info($this->LOG_FILE, $this->LOG_PREFIX . '.' . $o_2ro, $pwDm3); } protected function error($o_2ro, $pwDm3) { Logger::error($this->LOG_FILE, $this->LOG_PREFIX . '.' . $o_2ro, $pwDm3); } public function setBaseUrl($XNOq8) { $this->BASE_URL = $XNOq8; } protected function post($JPXsz, $f_HcG, $wCJen = array()) { goto Uibwc; EMb8F: $yCUD1 = CurlUtil::post($this->BASE_URL . $JPXsz, $f_HcG, $wCJen); goto V6F9w; duS96: return Response::generate(0, 'ok', $yCUD1['body']); goto ooaLv; Uibwc: if ($this->REQUEST_INTERVAL_US > 0) { usleep($this->REQUEST_INTERVAL_US); } goto a1Tlc; a1Tlc: $this->info('PostRequest', array($JPXsz, $f_HcG, $wCJen)); goto SwOlA; NOqtq: if (!isset($yCUD1['body'])) { $this->error('PostError', array($JPXsz, $f_HcG, $wCJen)); return Response::generate(-1, '请求失败(' . $JPXsz . ')'); } goto duS96; V6F9w: $this->info('PostResponse', array('elapse ' . intval((microtime(true) - $xc08J) * 1000) . 'ms', $JPXsz, $yCUD1)); goto NOqtq; SwOlA: $xc08J = microtime(true); goto EMb8F; ooaLv: } protected function postJSON($JPXsz, $f_HcG, $wCJen = array()) { goto u_b2c; jvk_d: $yCUD1 = CurlUtil::postJSON($this->BASE_URL . $JPXsz, $f_HcG, $wCJen); goto OUZNv; tW4zS: return $yCUD1; goto ltq1a; aTz9N: $this->info('PostJSONRequest', array($JPXsz, $f_HcG, $wCJen)); goto TZ0Ii; u_b2c: if ($this->REQUEST_INTERVAL_US > 0) { usleep($this->REQUEST_INTERVAL_US); } goto aTz9N; TZ0Ii: $xc08J = microtime(true); goto jvk_d; OUZNv: $this->info('PostJSONResponse', array('elapse ' . intval((microtime(true) - $xc08J) * 1000) . 'ms', $JPXsz, $yCUD1)); goto tW4zS; ltq1a: } protected function get($JPXsz, $f_HcG, $wCJen = array()) { goto Vgc08; VUWIg: $xc08J = microtime(true); goto lFXCF; ApM_2: return Response::generate(0, 'ok', $yCUD1['body']); goto whuTB; lFXCF: $yCUD1 = CurlUtil::get($this->BASE_URL . $JPXsz, $f_HcG, $wCJen); goto VKVQM; VKVQM: $this->info('GetRequest', array('elapse ' . intval((microtime(true) - $xc08J) * 1000) . 'ms', $JPXsz, $yCUD1)); goto ApM_2; Vgc08: if ($this->REQUEST_INTERVAL_US > 0) { usleep($this->REQUEST_INTERVAL_US); } goto iD6w_; iD6w_: $this->info('GetRequest', array($JPXsz, $f_HcG, $wCJen)); goto VUWIg; whuTB: } protected function getJSON($JPXsz, $f_HcG, $wCJen = array()) { goto EQ72q; j8sQx: $this->info('GetJSONRequest', array($JPXsz, $f_HcG, $wCJen)); goto rsc3y; UF4xu: $yCUD1 = CurlUtil::getJSON($this->BASE_URL . $JPXsz, $f_HcG, $wCJen); goto Zuge2; O5aCL: return $yCUD1; goto EwgiC; rsc3y: $xc08J = microtime(true); goto UF4xu; Zuge2: $this->info('GetJSONResponse', array('elapse ' . intval((microtime(true) - $xc08J) * 1000) . 'ms', $JPXsz, $yCUD1)); goto O5aCL; EQ72q: if ($this->REQUEST_INTERVAL_US > 0) { usleep($this->REQUEST_INTERVAL_US); } goto j8sQx; EwgiC: } }