|  | @@ -423,3 +423,46 @@ function get_client_ip() {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return $ip;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 通过CURL发送HTTP请求
 | 
	
		
			
				|  |  | + * @param string $url  //请求URL
 | 
	
		
			
				|  |  | + * @param array $postFields //请求参数
 | 
	
		
			
				|  |  | + * @return mixed
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function curlPost($url, $postFields) {
 | 
	
		
			
				|  |  | +    $postFields = json_encode($postFields);
 | 
	
		
			
				|  |  | +    $ch = curl_init();
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_URL, $url);
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 | 
	
		
			
				|  |  | +        'Content-Type: application/json; charset=utf-8'   //json版本需要填写  Content-Type: application/json;
 | 
	
		
			
				|  |  | +            )
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_POST, 1);
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
 | 
	
		
			
				|  |  | +    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 | 
	
		
			
				|  |  | +    $ret = curl_exec($ch);
 | 
	
		
			
				|  |  | +    if (false == $ret) {
 | 
	
		
			
				|  |  | +        $result = curl_error($ch);
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +        $rsp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 | 
	
		
			
				|  |  | +        if (200 != $rsp) {
 | 
	
		
			
				|  |  | +            $result = "请求状态 " . $rsp . " " . curl_error($ch);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            $result = $ret;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    curl_close($ch);
 | 
	
		
			
				|  |  | +    return $result;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +function getCacheById($key, $field) {
 | 
	
		
			
				|  |  | +    $redis = \app\common\Redis::instance(think\facade\Config::get("cache.stores.redis.select"));
 | 
	
		
			
				|  |  | +    $info = $redis->hGet($key, $field);
 | 
	
		
			
				|  |  | +    return json_decode($info, true);
 | 
	
		
			
				|  |  | +}
 |