zoukankan      html  css  js  c++  java
  • php微信开发-tp5下验证服务器的代码

    废话少说,直接上干货!

     1 <?php
     2 namespace appindexcontroller;
     3  
     4 use thinkController;
     5   
     6  
     7 
     8 Class Index extends Controller
     9 {
    10     public function index()//接收微信客户端发送的信息并回应! 
    11     { 
    12     
    13      //获得参数 signature nonce token timestamp echostr
    14         $nonce     = $_GET['nonce'];
    15         $token     = 'wexin';
    16         $timestamp = $_GET['timestamp'];
    17         $echostr   = $_GET['echostr'];
    18         $signature = $_GET['signature'];
    19         //形成数组,然后按字典序排序
    20         $array = array();
    21         $array = array($nonce, $timestamp, $token);
    22         sort($array);
    23         //拼接成字符串,sha1加密 ,然后与signature进行校验
    24         $str = sha1( implode( $array ) );
    25         if( $str  == $signature && $echostr ){
    26             //第一次接入weixin api接口的时候
    27             echo  $echostr;
    28             exit;
    29         }
    30     }
    31      
    32     
    33  
    34 }

    文件名为Index.php 是位于index模块下的Index控制器文件。

  • 相关阅读:
    python module introduce
    python代码基
    20100911部署更新
    汉王ocr
    wsgi
    css布局模板
    Making a simple web server in Python.
    20100910更新部署
    tw.forms usage
    python web shell
  • 原文地址:https://www.cnblogs.com/xiaogou/p/7100356.html
Copyright © 2011-2022 走看看