HARUHARU 4 lat temu
rodzic
commit
864a5fc9d9
2 zmienionych plików z 53 dodań i 0 usunięć
  1. 49 0
      application/common.php
  2. 4 0
      application/index/controller/Order.php

+ 49 - 0
application/common.php

@@ -56,6 +56,26 @@ function json_error($code,$msg='')
     json_return($error['code'],[],$error['msg']);
 }
 
+function http_get($url,$data)
+{
+    return json_decode(http_request('GET',$url,$data),true);
+}
+
+function http_post($url,$data)
+{
+    return json_decode(http_request('POST',$url,$data),true);
+}
+
+function http_request($method,$url,$data)
+{
+    $method = strtolower($method);
+    $params['method'] = $method;
+    $params['url'] = $url;
+    $params['data'] = $data;
+
+    return _curl($params);
+}
+
 /**
  * php发送http请求
  * @param array $params 相关请求参数
@@ -75,6 +95,8 @@ function _curl(array $params,$is_json=false )
         CURLOPT_TIMEOUT => 60,
         CURLOPT_SSL_VERIFYHOST=>2,
         CURLOPT_SSL_VERIFYPEER=>0,
+
+
     ];
     switch ($params['method'])
     {
@@ -126,6 +148,33 @@ function _curl(array $params,$is_json=false )
 
     return $result;
 }
+
+function request_post($url = '', $postData = []) {
+    if (empty($url)) {
+        return false;
+    }
+    $postUrl = $url;
+    //初始化curl //转义
+    $ch = curl_init();
+    if ($postData != []) {
+        $vars = http_build_query($postData, '', '&');
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
+    }
+    //抓取指定网页
+    curl_setopt($ch, CURLOPT_URL,$postUrl);
+    //设置header
+    curl_setopt($ch, CURLOPT_HEADER, 0);
+    //要求结果为字符串且输出到屏幕上
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    //规避SSL验证
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+    //跳过HOST验证
+    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+    //运行curl
+    $data = curl_exec($ch);
+    curl_close($ch);
+    return $data;
+}
 /**
  * 统一返回信息
  * @param $code

+ 4 - 0
application/index/controller/Order.php

@@ -9,9 +9,13 @@ use think\Controller;
 
 class Order extends Base
 {
+    const base_url = 'https://yxmall-adminportal.eavic.com/oms-web/box';
+
     public function CheckOrder(){
         $order_sn = input('param.order_sn');
         //商网接口
+        $result = request_post(self::base_url . '/deliver.do' , ['order_sn' => $order_sn]);
+        pre($result);
         json_success();
     }