1. 程式人生 > >微信公眾號開發者驗證

微信公眾號開發者驗證

很久沒碰公眾號開發了 今天幫別人開發公眾號 重新記錄一下

/**
 * 驗證方法
 * @return bool
 */
function checkSignature(){
    $signature = $_GET["signature"];
    $tmpArr = [
        'timestamp' => $_GET["timestamp"],
        'nonce' => $_GET["nonce"],
        'token' => 'xxx',
    ];
    sort($tmpArr);
    $tmpStr = implode
( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $signature == $tmpStr ){ return $_GET['echostr']; }else{ return false; } } $res = checkSignature(); if($res){ echo $res; }

 

寫到一個可以訪問的php檔案裡 然後將這個php 檔案的訪問地址 填到 驗證url 裡面 填寫其它資料 提交就可以了