Browse Source

Merge branch 'master' of http://git.huxiukeji.com/lizhen/lanjingling

lizhen_gitee 1 year ago
parent
commit
da6f0995f9
2 changed files with 63 additions and 0 deletions
  1. 32 0
      application/api/controller/Message.php
  2. 31 0
      public/test.php

+ 32 - 0
application/api/controller/Message.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+
+class Message extends Api
+{
+    protected $noNeedLogin = '*';
+    protected $noNeedRight = '*';
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = Db::name('pre_order');
+    }
+
+    /**
+     * index
+     * @return void
+     */
+    public function index()
+    {
+        try {
+            echo true;
+        } catch (Exception $e) {
+            echo false;
+        }
+    }
+}

+ 31 - 0
public/test.php

@@ -0,0 +1,31 @@
+<?php
+
+printLog(json_encode($_GET));
+$signature = $_GET["signature"];
+$timestamp = $_GET["timestamp"];
+$nonce = $_GET["nonce"];
+$echostr = $_GET["echostr"];
+$token = "lanjingling";
+$tmpArr = array($token, $timestamp, $nonce);
+sort($tmpArr, SORT_STRING);
+$tmpStr = implode( $tmpArr );
+$tmpStr = sha1( $tmpStr );
+printLog("tmpStr:".$tmpStr);
+printLog("signature:".$signature);
+if( $tmpStr == $signature ){
+    echo  $echostr;
+}else{
+    echo  false;
+}
+/**
+ * 打印数据
+ * @param  string $txt  日志记录
+ * @param  string $file 日志目录
+ * @return
+ */
+function printLog($txt="",$file="ceshi.log"){
+    $myfile = fopen($file, "a+");
+    $StringTxt = "[".date("Y-m-d H:i:s")."]".$txt."\n";
+    fwrite($myfile, $StringTxt);
+    fclose($myfile);
+}