亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

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

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

<?php
namespace app\index\controller;

use think\Request,think\Db;
use think\Cache;
class Autoreply extends RestBase{
    // 獲取微信數(shù)據(jù)
    public function checktoken(){
        $request = Request::instance();
        $get = $request->param();
        $timestamp = $get['timestamp'];//timestamp其實(shí)就是一個(gè)時(shí)間戳  
        $nonce     = $get['nonce'];//nonce是一個(gè)隨機(jī)參數(shù)  
        $token     = "";//這個(gè)token填寫(xiě)你在微信公眾平臺(tái)上寫(xiě)的那個(gè)值  
        $signature = $get['signature'];//這個(gè)signature其實(shí)就是在微信公眾平臺(tái)已經(jīng)加密好的字符串  
        $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年軟件開(kāi)發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級(jí)軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

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