WeChat public platform - thinkphp5 WeChat server configuration problem, why the token cannot be verified
高洛峰
高洛峰 2017-06-17 09:15:26
0
1
894

Now that the verification has passed, the only thing left is to return it to WeChat. If I return echostr or true, WeChat says my token verification failed

param(); $timestamp = $get['timestamp'];//timestamp其实就是一个时间戳 $nonce = $get['nonce'];//nonce是一个随机参数 $token = "";//这个token填写你在微信公众平台上写的那个值 $signature = $get['signature'];//这个signature其实就是在微信公众平台已经加密好的字符串 $echostr = $get['echostr']; $array = array(); $array = array($token,$timestamp,$nonce); sort($array); $tmpstr = sha1(implode('',$array)); if($tmpstr == $signature){ echo $get['echostr']; }else{ return false; } } }
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all (1)
typecho

When you carefully look at the code and can't find any problems, it's more important to learn simple debugging, such as seeing what the WeChat parameters are, and seeing whether the results you processed are the same as you expected.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!