test.php 750 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. printLog(json_encode($_GET));
  3. $signature = $_GET["signature"];
  4. $timestamp = $_GET["timestamp"];
  5. $nonce = $_GET["nonce"];
  6. $echostr = $_GET["echostr"];
  7. $token = "lanjingling";
  8. $tmpArr = array($token, $timestamp, $nonce);
  9. sort($tmpArr, SORT_STRING);
  10. $tmpStr = implode( $tmpArr );
  11. $tmpStr = sha1( $tmpStr );
  12. printLog("tmpStr:".$tmpStr);
  13. printLog("signature:".$signature);
  14. if( $tmpStr == $signature ){
  15. echo $echostr;
  16. }else{
  17. echo false;
  18. }
  19. /**
  20. * 打印数据
  21. * @param string $txt 日志记录
  22. * @param string $file 日志目录
  23. * @return
  24. */
  25. function printLog($txt="",$file="ceshi.log"){
  26. $myfile = fopen($file, "a+");
  27. $StringTxt = "[".date("Y-m-d H:i:s")."]".$txt."\n";
  28. fwrite($myfile, $StringTxt);
  29. fclose($myfile);
  30. }