[代码]php代码:<?php define ( "TOKEN", "这里填写你提交时填写的token" ); $wechatObj = new wechatCallbackapiTest(); $wechatObj->valid(); class wechatCallbackapiTest { public function valid() { $echoStr = $_GET["echostr"]; //随机字符串 if($this->checkSignature()){ echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET ["signature"]; $timestamp = $_GET ["timestamp"]; $nonce = $_GET ["nonce"]; $token = TOKEN; $tmpArr = array ( $token, $timestamp, $nonce ); sort ( $tmpArr ); $tmpStr = implode ( $tmpArr ); $tmpStr = sha1 ( $tmpStr ); if ($tmpStr == $signature) { return true; } else { return false; } } } PHP技术交流QQ群:422137578 除非注明,文章均为 PHP二次开发 原创,转载请注明本文地址:http://www.php2.cc/article-586-1.html |