基本信息
源码名称:《微信公众平台应用开发实战》php源码
源码大小:0.07M
文件格式:.zip
开发语言:PHP
更新时间:2016-04-11
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元×
微信扫码支付:3 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
<?php $startTime = microtime(true); require_once dirname(__FILE__) . '/common/Common.php'; function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = WEIXIN_TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } /* if(checkSignature()) { if($_GET["echostr"]) { echo $_GET["echostr"]; exit(0); } } else { //恶意请求:获取来来源ip,并写日志 $ip = getIp(); interface_log(ERROR, EC_OTHER, 'malicious: ' . $ip); exit(0); } */ function getWeChatObj($toUserName) { if($toUserName == USERNAME_FINDFACE) { require_once dirname(__FILE__) . '/class/WeChatCallBackFindFace.php'; return new WeChatCallBackFindFace(); } if($toUserName == USERNAME_MR) { require_once dirname(__FILE__) . '/class/WeChatCallBackMeiri10futu.php'; return new WeChatCallBackMeiri10futu(); } if($toUserName == USERNAME_ES) { require_once dirname(__FILE__) . '/class/WeChatCallBackEchoServer.php'; return new WeChatCallBackEchoServer(); } if($toUserName == USERNAME_MYZL) { require_once dirname(__FILE__) . '/class/WeChatCallBackMYZL.php'; return new WeChatCallBackMYZL(); } require_once dirname(__FILE__) . '/class/WeChatCallBack.php'; return new WeChatCallBack(); } function exitErrorInput(){ echo 'error input!'; interface_log(INFO, EC_OK, "***** interface request end *****"); interface_log(INFO, EC_OK, "*********************************"); interface_log(INFO, EC_OK, ""); exit ( 0 ); } $postStr = file_get_contents ( "php://input" ); interface_log(INFO, EC_OK, ""); interface_log(INFO, EC_OK, "***********************************"); interface_log(INFO, EC_OK, "***** interface request start *****"); interface_log(INFO, EC_OK, 'request:' . $postStr); interface_log(INFO, EC_OK, 'get:' . var_export($_GET, true)); if (empty ( $postStr )) { interface_log ( ERROR, EC_OK, "error input!" ); exitErrorInput(); } // 获取参数 $postObj = simplexml_load_string ( $postStr, 'SimpleXMLElement', LIBXML_NOCDATA ); if(NULL == $postObj) { interface_log(ERROR, 0, "can not decode xml"); exit(0); } $toUserName = ( string ) trim ( $postObj->ToUserName ); if (! $toUserName) { interface_log ( ERROR, EC_OK, "error input!" ); exitErrorInput(); } else { $wechatObj = getWeChatObj ( $toUserName ); } $ret = $wechatObj->init ( $postObj ); if (! $ret) { interface_log ( ERROR, EC_OK, "error input!" ); exitErrorInput(); } $retStr = $wechatObj->process (); interface_log ( INFO, EC_OK, "response:" . $retStr ); echo $retStr; interface_log(INFO, EC_OK, "***** interface request end *****"); interface_log(INFO, EC_OK, "*********************************"); interface_log(INFO, EC_OK, ""); $useTime = microtime(true) - $startTime; interface_log ( INFO, EC_OK, "cost time:" . $useTime . " " . ($useTime > 4 ? "warning" : "") ); ?>