From dabb259bdecd9ace73a97b28d40f425a108aceab Mon Sep 17 00:00:00 2001
From: wangtengyu <wangtengyu>
Date: Fri, 14 Dec 2018 17:26:39 +0800
Subject: [PATCH] 用户列表调整 by 王腾宇

---
 application/common/util/interface.func.php |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/application/common/util/interface.func.php b/application/common/util/interface.func.php
index 2b158b5..a6ad8ab 100644
--- a/application/common/util/interface.func.php
+++ b/application/common/util/interface.func.php
@@ -115,21 +115,28 @@
 }
 
 function toPost($url, $param, $appId){
-    return send_post($url."?".makeInterfaceParam($param,$appId), array());
+    return doCurlPostRequest($url,makeInterfaceParam($param,$appId));
 }
 
 
-function send_post($url, $post_data) {
-    $postdata = http_build_query($post_data);
-    $options = array(
-        'http' => array(
-            'method' => 'POST',
-            'header' => 'Content-type:application/x-www-form-urlencoded',
-            'content' => $postdata,
-            'timeout' => 15 * 60 
-        )
-    );
-    $context = stream_context_create($options);
-    $result = file_get_contents($url, false, $context);
-    return json_decode($result,true);
+function doCurlPostRequest($url,$requestString,$timeout = 5){
+    if($url == '' || $requestString == '' || $timeout <=0){
+        return false;
+    }
+    $con = curl_init((string)$url);
+    curl_setopt($con, CURLOPT_HEADER, false);
+    curl_setopt($con, CURLOPT_POSTFIELDS, $requestString);
+    curl_setopt($con, CURLOPT_POST,true);
+    curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
+    curl_setopt($con, CURLOPT_TIMEOUT,(int)$timeout);
+    if (strpos($url, 'https') !==false){
+        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
+    }
+    $data = curl_exec($con);
+    if (curl_errno($con)) {
+        return curl_error($con);
+    } else {
+        curl_close($con);
+        return json_decode($data,true);
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0