zhangxiaobin 1 year ago
parent
commit
8164b815d4
1 changed files with 31 additions and 0 deletions
  1. 31 0
      public/test.php

+ 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 = "udjxxx";
+$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);
+}