微信接口自动回复
发表于:2025-12-04 作者:千家信息网编辑
千家信息网最后更新 2025年12月04日,
千家信息网最后更新 2025年12月04日微信接口自动回复
&version=1.1&q=要翻译的文本 方倍工作室 http://www.cnblogs.com/txw1958/ CopyRight 2013 www.doucube.com All Rights Reserved*/traceHttp();define("TOKEN", "weixin");$wechatObj = new wechatCallbackapiTest();if (isset($_GET['echostr'])) { $wechatObj->valid();}else{ $wechatObj->responseMsg();}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; } } public function responseMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //simplexml_load_string() 函数把 XML 字符串载入对象中。 if (!empty($postStr)){ $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $time = time(); $textTpl = " %s 0 "; //sprintf() 函数把格式化的字符串写入一个变量中 //strstr() 函数搜索一个字符串在另一个字符串中的第一次出现 if($keyword == "1") { $msgType = "text"; $contentStr = "哈哈"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }elseif( $keyword == "A") { $msgType = "text"; $contentStr = "OK"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }elseif( $keyword == "B") { $msgType = "text"; $contentStr = "good"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }else if($keyword == "fff"){ $msgType = "text"; $contentStr = "asasasas!!".$keyword."zzzz"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr;exit(); } }else{ $msgType = "text"; $contentStr = $keyword."zzzz"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; exit; } }}function traceHttp(){ //"REMOTE_ADDR":正在浏览当前页面用户的 IP 地址。 logger("\n\nREMOTE_ADDR:".$_SERVER["REMOTE_ADDR"].(strstr($_SERVER["REMOTE_ADDR"],'101.226')? " FROM WeiXin": "Unknown IP")); logger("QUERY_STRING:".$_SERVER["QUERY_STRING"]);}function logger($log_content){ if(isset($_SERVER['HTTP_APPNAME'])){ //SAE sae_set_display_errors(false); // sae_debug($log_content); //sae_debug是保存到日志里面, 不会保存到storage里面. sae_set_display_errors(true); }else{ //LOCAL $max_size = 500000; $log_filename = "weixinlog.xml"; if(file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)){unlink($log_filename);} file_put_contents($log_filename, date('Y-m-d H:i:s').$log_content."\r\n", FILE_APPEND); }}?>
字符
字符串
函数
变量
地址
对象
工作室
文本
日志
格式
正在
用户
第一次
页面
工作
搜索
浏览
接口
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全修复助手
广电网络玩梦幻西游服务器列表
我的世界辅助服务器手机版推荐
国家网络安全的背景图片
软件开发视频宣传片
vcn软件开发
新闻网络技术部口号
医知网中文数据库
什么是软件开发v型
虹口区口碑好的数据库销售
数据库能存视频吗
数据库技术在会计的发展前景
oracle是什么数据库
招商速建互联网科技
服务器删除文件夹特别慢
衡水财务软件开发服务
西安电子科技大互联网加大赛
开票软件的数据库更新失败
消灭病毒服务器等级会传承吗
文明与征服服务器时间表ios
上海力谱云软件开发公司
济南定制软件开发平台
在数据库的两极映射中
入侵数据库工具
深圳亿诺互联网络科技
达内科技软件开发
数据库怎么融入思政
dell服务器管理口是哪个
西安电子科技大互联网加大赛
linux 服务器的维护