wx.php 821 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * 微信接口
  4. */
  5. define('IN_WEB', true);
  6. $sid = 1;
  7. $lid = 1;
  8. include_once dirname(__FILE__) . "/../com.php";
  9. $encodingAesKey = 'IN5dJxVNFHJhl8Kw8eypMpreD71eXK3BDhfqKG6W8jI';
  10. $appId = 'wx921fc9b6c72d721a';
  11. $token = 'superant2017';
  12. //验证消息来源是否为微信服务器
  13. function checkSignature(){
  14. global $token;
  15. $signature = $_GET['signature'];
  16. $timestamp = $_GET['timestamp'];
  17. $nonce = $_GET['nonce'];
  18. $echostr = $_GET['echostr'];
  19. $tmpArr = array( $token, $timestamp, $nonce);
  20. sort($tmpArr, SORT_STRING);
  21. $tmpStr = implode( $tmpArr );
  22. $tmpStr = sha1( $tmpStr );
  23. if ($tmpStr === $signature){
  24. return $echostr;
  25. }else{
  26. return false;
  27. }
  28. }
  29. $fromwxserver = checkSignature();
  30. echo $fromwxserver;