<?php
/**
 * 微信接口
 */
define('IN_WEB', true);


$sid = 1;
$lid = 1;

include_once dirname(__FILE__) . "/../com.php";

$encodingAesKey = 'IN5dJxVNFHJhl8Kw8eypMpreD71eXK3BDhfqKG6W8jI';
$appId          = 'wx921fc9b6c72d721a';
$token          = 'superant2017';

//验证消息来源是否为微信服务器
function checkSignature(){
    global $token;
    $signature      = $_GET['signature'];
    $timestamp      = $_GET['timestamp'];
    $nonce          = $_GET['nonce'];
    $echostr        = $_GET['echostr'];

    $tmpArr = array( $token, $timestamp, $nonce);
    sort($tmpArr, SORT_STRING);
    $tmpStr = implode( $tmpArr );
    $tmpStr = sha1( $tmpStr );

    if ($tmpStr === $signature){
        return $echostr;
    }else{
        return false;
    }
}

$fromwxserver = checkSignature();
echo $fromwxserver;