wupengfei vor 2 Jahren
Ursprung
Commit
6802a9fcfd
3 geänderte Dateien mit 68 neuen und 30 gelöschten Zeilen
  1. 8 7
      .idea/workspace.xml
  2. 42 0
      application/api/controller/Expedite.php
  3. 18 23
      application/common.php

+ 8 - 7
.idea/workspace.xml

@@ -3,7 +3,8 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/application/api/controller/UserCenter.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/UserCenter.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/controller/Expedite.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Expedite.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -121,7 +122,7 @@
   <component name="PropertiesComponent">
     <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
     <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/application/common/model" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/../xixie" />
     <property name="node.js.detected.package.eslint" value="true" />
     <property name="node.js.detected.package.tslint" value="true" />
     <property name="node.js.path.for.package.eslint" value="project" />
@@ -211,7 +212,7 @@
       <workItem from="1672793834653" duration="24306000" />
       <workItem from="1672880479757" duration="22897000" />
       <workItem from="1672966192005" duration="19617000" />
-      <workItem from="1673052319155" duration="8045000" />
+      <workItem from="1673052319155" duration="13819000" />
     </task>
     <servers />
   </component>
@@ -341,10 +342,10 @@
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
     <state x="283" y="145" width="1942" height="1088" key="DiffContextDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1672820850032" />
-    <state x="1418" y="514" key="FileChooserDialogImpl" timestamp="1672985053345">
+    <state x="1418" y="514" key="FileChooserDialogImpl" timestamp="1673071857948">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
-    <state x="1418" y="514" key="FileChooserDialogImpl/0.0.2560.1400@0.0.2560.1400" timestamp="1672985053345" />
+    <state x="1418" y="514" key="FileChooserDialogImpl/0.0.2560.1400@0.0.2560.1400" timestamp="1673071857948" />
     <state x="1051" y="472" key="MultipleFileMergeDialog" timestamp="1671416392056">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
@@ -374,10 +375,10 @@
     </state>
     <state x="875" y="449" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.1920.1040@0.0.1920.1040" timestamp="1665835639346" />
     <state x="1166" y="605" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.2560.1400@0.0.2560.1400" timestamp="1673053690530" />
-    <state x="1057" y="460" width="746" height="548" key="find.popup" timestamp="1672987034068">
+    <state x="1057" y="460" width="746" height="548" key="find.popup" timestamp="1673072066577">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
-    <state x="1057" y="460" width="746" height="548" key="find.popup/0.0.2560.1400@0.0.2560.1400" timestamp="1672987034068" />
+    <state x="1057" y="460" width="746" height="548" key="find.popup/0.0.2560.1400@0.0.2560.1400" timestamp="1673072066577" />
     <state x="1291" y="317" key="run.anything.popup" timestamp="1672903043103">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>

+ 42 - 0
application/api/controller/Expedite.php

@@ -582,6 +582,48 @@ class Expedite extends Base
 
 
     /**
+     * @title 获取分享链接
+     * @desc 获取分享链接
+     * @url /api/Expedite/getUrlScheme
+     * @method POST
+     * @param  name:url type:string default:-- desc:页面地址
+     * @return name:appid type:string default:-- desc:appid
+     **/
+    public function getUrlScheme()
+    {
+        $appid = config('app.mini_program')['app_id'];
+        $secret =  config('app.mini_program')['secret'];
+        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
+        $res= http_curl($url);
+        $access_token = $res['access_token'];
+        $api_url = 'https://api.weixin.qq.com/wxa/generatescheme?access_token='.$access_token;
+
+        $url_scheme = curl_post($api_url,[]);
+        $this->success('ok',['url'=>$url_scheme['openlink']]);
+    }
+
+
+    /**
+     * @title getUrlLink
+     * @desc getUrlLink
+     * @url /api/Expedite/getUrlLink
+     * @method POST
+     * @param  name:url type:string default:-- desc:页面地址
+     * @return name:appid type:string default:-- desc:appid
+     **/
+    public function getUrlLink()
+    {
+        $appid = config('app.mini_program')['app_id'];
+        $secret =  config('app.mini_program')['secret'];
+        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
+        $res= http_curl($url);
+        $access_token = $res['access_token'];
+        $api_url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token='.$access_token;
+        $url_link = curl_post($api_url,[]);
+        $this->success('ok',['url'=>$url_link['url_link']]);
+    }
+
+    /**
      * @title 获取平台文案设置
      * @desc  获取平台文案设置
      * @author  qc

+ 18 - 23
application/common.php

@@ -362,32 +362,27 @@ function pdfCurl($file_name)
     return  json_decode($result,true);
 }
 
-function curlPost($url, $post_data = array(), $timeout = 5, $header = "", $data_type = "") {
-    $header = empty($header) ? '' : $header;
-    //支持json数据数据提交
-    if($data_type == 'json'){
-        $post_string = json_encode($post_data);
-    }
-    else if(is_array($post_data)){
-        $post_string = http_build_query($post_data, '', '&');
-    }else {
-        $post_string = $post_data;
-    }
+function curl_post($url,$post_data)
+{
+    // 1. 初始化一个cURL会话
+    //根据API的要求,定义相对应的Content-Type
+    $headers = [];
+    array_push($headers, "Content-Type".":"."application/json");
     $ch = curl_init();
-    curl_setopt($ch, CURLOPT_POST, true);
-    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
+    // 2. 设置请求选项, 包括具体的url
+    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_URL, $url);
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    // https请求 不验证证书和hosts
-    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
-    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
-    curl_setopt($ch, CURLOPT_HTTPHEADER, array($header)); //模拟的header头
-    $info = curl_getinfo($ch);
-    $result = curl_exec($ch);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    // 设置请求为post类型
+    curl_setopt($ch, CURLOPT_POST, 1);
+    // 添加post数据到请求中
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+    curl_setopt($ch, CURLOPT_HEADER, 0);
+    // 3. 执行一个cURL会话并且获取相关回复
+    $response = curl_exec($ch);
+    // 4. 释放cURL句柄,关闭一个cURL会话
     curl_close($ch);
-
-    return $result;
+    return  json_decode($response,true);
 }
 
 function getVideoTime($ali_id)