解决微信小程序消息推送配置Token校验失败问题 

如果是Token校验失败问题,一种是URL地址访问不通,第二种是验证是返回给微信服务数据问题.

1.填写配置信息小程序

URL(服务器地址):用url访问文件名地址

Token: 自己随便起个名字就行英文数字3-32字符;

EncodingAESKey:直接用服务器生成即可

配置完成后,微信服务器会访问服务器地址检验是否能访问到。如果访问失败获取返回数据不正确,将提示token校验失败

将下面代码复制到文件中即可,我的是wxServiceResult.php文件

?phpprintLog(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."";fwrite($myfile, $StringTxt);fclose($myfile);    }?

点击提交出现小程序

说明配置成功

TAG标签: 微信小程序token验证失败

http://www.xiaochengxub.com/read-105447.html