问答详情
源自:2-4 基于ThinkPHP框架的微信API接入

token验证失败

<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
    public function index(){
        $nonce = $_GET['nonce'];
        $token     = 'weixin';
        $timestamp = $_GET['timestamp'];
        $echostr   = $_GET['echostr'];
        $signature = $_GET['signature'];
        //形成数组,然后按字典序排序
        $array = array();
        $array = array($nonce, $timestamp, $token);
        sort($array);
        //拼接成字符串,sha1加密 ,然后与signature进行校验
        $str = sha1( implode( $array ) );
        if( $str  == $signature ){
            //第一次接入weixin api接口的时候
            echo  $echostr;
            exit;
        }
        
    }
    
    public function show()
    {
        echo 'hi' ;
    }


没套框架的时候验证通过了, 套上框架就GG了,然后测试show()的时候也能显示成功。。


提问者:原来这是昵称 2015-11-08 22:01

个回答

  • 海角嘚天涯
    2015-12-08 22:59:33

    求助啊,验证失败

  • _茅草屋
    2015-11-14 10:35:42

     我的也是。现在还是没搞出来,求解

  • 原来这是昵称
    2015-11-11 14:02:52

    额 , 解决了,,