79524795-Tian

1.公众号基本配置(token验证失败)

<?php
define("TOKEN", "你自己的token");

$wechatObj = new CallbackAPI;
$wechatObj->valid();

class CallbackAPI {

    /**
     * 签名验证
     * @return [type] [description]
     */
     public function valid() {
        $echoStr = $_GET["echostr"];
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];
        $token = TOKEN;
        //将token、timestamp、nonce按字典序排序
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr);
        $tmpStr = implode($tmpArr);
        //对tmpStr进行sha1加密
        $tmpStr = sha1($tmpStr);
        if($tmpStr == $signature){
            header(\'content-type:text\');
            echo $echoStr;
            exit;
        }
    }
}

2.公众平台测试账号接口配置信息(token验证失败)

 

<?php 


 //微信服务器发送过来的 :接受get参数
 
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];

        //自己定义的TOKEN    
        $token = \'phplove1\';

         $echostr   = $_GET[\'echostr\'];
         @file_put_contents(\'Public/checksing.html\', \'<br/>\'.$signature.\'-\'.$timestamp.\'-\'.$nonce.\'-\'.$token, FILE_APPEND);
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );
        @file_put_contents(\'Public/checksing.html\', \'<br/>\'.$tmpStr.\'--\'.$echostr, FILE_APPEND);
       
           //进行比对
        if( $signature ){
            echo  $echostr;
        }else{
            return false;
        }

 

分类:

技术点:

相关文章:

  • 2022-01-14
  • 2022-02-09
  • 2021-06-15
  • 2022-12-23
  • 2021-06-30
  • 2021-04-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-11
  • 2022-01-12
  • 2022-02-18
  • 2021-12-27
  • 2021-10-02
  • 2021-04-02
  • 2022-01-28
相关资源
相似解决方案