微信官方网站验证失败怎么办

推荐这篇日记的豆列
······为什么微信验证通过不了? - 开源中国社区
当前访客身份:游客 [
当前位置:
你好,想跟你请教个问题:
将$this-&runMode = '';改为:valid。进行微信 验证,提示 “请求URL超时”是怎么回事?!
将$config['cmd_expire_time'] = 3000;也没有作用。
我的测试地址是:
---------------问题补充---------------
:发现一个现象,如果直接用 index.php或者/weixin/ (即不写index.php),则微信的参数是直接空格之后附加在这后面的,而不是加一个 问号。就会出现404错误
如果手动加个问号,和微信的这些参数,是能正常返回值的。
然后问题就在于:
但在微信提交indx.php?(即包括问号),则微信不返回任何参数,直接无视这个URL的意思。
在结尾不加问号,则CI又无法识别参数。
:上面问号的问题是我错了,IIS的日志原来不显示问号的。
所以现在的问题就是,
实际上这个robot返回的验证码其实是正确的。但为什么我用微信的那个代码就能成功通过验证,为robot这个代码,就通过不了呢?
共有22个答案
<span class="a_vote_num" id="a_vote_num_
http://******/index.php/login/chkLogin
<span class="a_vote_num" id="a_vote_num_
引用来自“junxincom”的答案 找到问题了。
原来编码UTF-8。必须是ANSI!!!
估计是web服务程序的问题吧,我在win/linux下均 使用UTF8编码通过验证,以及收发信息,没有遇到任何问题
不过,提出了这个可能,对于其他遇到类似问题的朋友,也是一个很好的参考
<span class="a_vote_num" id="a_vote_num_
找到问题了。
原来编码UTF-8。必须是ANSI!!!
<span class="a_vote_num" id="a_vote_num_
引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?! 你的不可以吗?你直接用示例代码都能通过验证的吧? 是的,换成示例代码,就直接通过了。
示例代码的地址是:http://42.121.122.74/weixin.php
我已经不知道问题是怎么回事了。 你可以把你的代码贴出来一下,说不定能找到问题 示例代码就是微信的那个。
* wechat php test
//define your token
define(&TOKEN&, &junxin&);
$wechatObj = new wechatCallbackapiTest();
$wechatObj-&valid();
class wechatCallbackapiTest
public function valid()
$echoStr = $_GET[&echostr&];
//valid signature , option
if($this-&checkSignature()){
echo $echoS
public function responseMsg()
//get post data, May be due to the different environments
$postStr = $GLOBALS[&HTTP_RAW_POST_DATA&];
//extract post data
if (!empty($postStr)){
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUsername = $postObj-&FromUserN
$toUsername = $postObj-&ToUserN
$keyword = trim($postObj-&Content);
$time = time();
$textTpl = &&xml&
&ToUserName&&![CDATA[%s]]&&/ToUserName&
&FromUserName&&![CDATA[%s]]&&/FromUserName&
&CreateTime&%s&/CreateTime&
&MsgType&&![CDATA[%s]]&&/MsgType&
&Content&&![CDATA[%s]]&&/Content&
&FuncFlag&0&/FuncFlag&
if(!empty( $keyword ))
$msgType = &text&;
$contentStr = &Welcome to wechat world!&;
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultS
echo &Input something...&;
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 ){
?& 而且现在通过不了的,就是
的代码啊。配置什么的都做了,就是过不了。
贴一个homephp的代码(好像意义不太大)
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Home extends CI_Controller {
private $runMode = '';
public function __construct() {
parent::__construct();
$this-&load-&library('wechat');
* 运行模式
* 可选: [test][valid][...]
* test: 测试模式,将测试用的XML数据引入程序
* valid: 验证模式,当在微信公众平台开启开发模式时需验证服务器是否配置正确使用
* ...: 除以上状态外的任意设置都是正常运行模式,将正常接收及响应用户的消息
$this-&runMode = 'valid';
public function index() {
switch ($this-&runMode) {
case 'test':
//测试模式
$platform_opn_id = 'platform_opn_id';
$user_opn_id = 'user_opn_id';
$content = 'testfun#123123';
$content = 'cd#5';
$content = 'dc#150';
$content = 'gs#3';
$content = 'dh#';
$content = 'dh#3555555';
$content = 'dz#';
$content = 'dz#安新南区356栋3楼';
$content = 'qr#1';
$xml = '&xml&
&ToUserName&&![CDATA[' . $platform_opn_id . ']]&&/ToUserName&
&FromUserName&&![CDATA[' . $user_opn_id . ']]&&/FromUserName&
&CreateTime&' . time() . '&/CreateTime&
&MsgType&&![CDATA[text]]&&/MsgType&
&Content&&![CDATA[' . $content . ']]&&/Content&
&MsgId&6371514&/MsgId&
$xml = '&xml&
&ToUserName&&![CDATA[' . $platform_opn_id . ']]&&/ToUserName&
&FromUserName&&![CDATA[' . $user_opn_id . ']]&&/FromUserName&
&CreateTime&' . time() . '&/CreateTime&
&MsgType&&![CDATA[event]]&&/MsgType&
&Event&&![CDATA[subscribe]]&&/Event&
&EventKey&&![CDATA[]]&&/EventKey&
$msg = $this-&wechat-&resloveMsg($xml);
if (!is_object($msg)) {
exit($msg);
$this-&_MsgByType($msg-&msgArr['msgtype'], $msg);
case 'valid':
//验证模式
$this-&wechat-&valid($_GET);
//普通运行模式
$postStr = @$GLOBALS['HTTP_RAW_POST_DATA'];
if (!$postStr) {
echo 'err_no_data_gained';
$msg = $this-&wechat-&resloveMsg($postStr);
if (!is_object($msg)) {
exit($msg);
$this-&_MsgByType($msg-&msgArr['msgtype'], $msg);
* 黑名单验证
private function _isBanned($user_opn_id) {
$this-&load-&model('blacklists_model', 'bl');
if (FALSE !== $this-&bl-&get($user_opn_id)) {
return TRUE;
return FALSE;
* 按照不同的消息类型处理
* 目前仅处理文本与事件消息
private function _MsgByType($msgType, $msg) {
//黑名单验证
if ($this-&_isBanned($msg-&msgArr['user_opn_id'])) {
* 用户已被ban,退出
* 这里可以输出一些信息给用户,我就不做了,有兴趣的话可以实现
exit('err_user_has_been_banned');
switch ($msgType) {
case 'text'://文本
$this-&_MsgText($msg);
case 'image'://图像
$this-&_MsgImage();
case 'location'://坐标
$this-&_MsgLocation();
case 'link'://超链接
$this-&_MsgLink();
case 'event'://事件
$this-&_MsgEvent($msg);
case 'voice'://语音
$this-&_MsgVoice();
default://未知类型
$this-&_sendHelpMsg($msg, 'unknown_msg_type');
* 帮助信息
* 这里用作没有匹配到消息类型或者没有合适关键字的时候均调用本过程
* 通常输出一些帮助信息文本
private function _sendHelpMsg($msg, $debug_msg = '') {
* 仅在测试模式下,会将调用本函数时携带的调试信息随着text输出
//获取帮助信息
$k = $this-&_getKeyword(0, $this-&wechat-&help_keyword);
$r = $this-&_getReply($k-&id);
if ('test' == $this-&runMode) {
$r-&content .= &\n\n debug_msg:& . $debug_
$this-&_sendMsg($msg, $r);
* 获取关键字
private function _getKeyword($msgtype_id, $keyword) {
$this-&load-&model('keywords_model', 'keywords');
* 此处getKeyword默认为全匹配模式,同样支持模糊匹配模式
* 具体请查看keywords_model
$keywords = $this-&keywords-&getKeyword($keyword, 0, $msgtype_id, 0);
if (FALSE !== $keywords) {
return $keywords[array_rand($keywords)];
//未查询到合适的关键字
return FALSE;
* 判断用户信息是否含有指定的命令标识
private function _isTextCmd($msg) {
//命令标识
$cmd_sign = $this-&wechat-&cmd_
$content = json_decode($msg-&msgArr['content'])-&C
//检查消息内是否有命令标识
if (FALSE === strpos($content, $cmd_sign)) {
return FALSE;
return TRUE;
* 判断命令是否超时
private function _isExpire($user_datas) {
$cmd_expire_time = $this-&wechat-&cmd_expire_
//当前时间 - 用户上次命令时间 & 超时设置 =& 已超时
if (time() - $user_datas-&last_time & $cmd_expire_time) {
return TRUE;
return FALSE;
* 获取命令设置
private function _getCmd($cmd) {
$this-&load-&model('commands_model', 'cmds');
return $this-&cmds-&get($cmd, 0);
* 获取用户数据
private function _getDatas($user_opn_id) {
$this-&load-&model('datas_model', 'datas');
$d = $this-&datas-&get($user_opn_id);
//查询的用户数据不存在,则新增一条数据
if (FALSE === $d) {
if ($this-&datas-&add($user_opn_id) & 0) {
return $this-&datas-&get($user_opn_id);
return $d;
* 处理文本命令信息
private function _MsgCmd($msg) {
$matches = NULL;
//命令标识
$cmd_sign = $this-&wechat-&cmd_
//分解消息
$msg_content = explode($cmd_sign, json_decode($msg-&msgArr['content'])-&Content);
$cmd = $this-&_getCmd(strtolower($msg_content[0]));
dump($cmd);
//用户输入的命令不存在
if (FALSE === $cmd) {
$this-&_sendMsg($msg, $this-&_getCmd('err_invlid_command'));
log_message('error', 'err_invlid_command');
$command = $cmd-&
//获取用户数据
$user_datas = $this-&_getDatas($msg-&msgArr['user_opn_id']);
//将用户已经保存的数据转化成对象
$data = json_decode(isset($user_datas-&data) ? $user_datas-&data : '');
if (FALSE == $data) {
//若用户未有保存过的数据则新建一个对象
$data = new stdClass();
//检查当前命令是否有超时设置,并检查是否超时
if (1 === intval($cmd-&is_expire)) {
if ($this-&_isExpire($user_datas)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_command_expired'));
log_message('error', 'err_command_expired');
//检查当前输入命令的父命令
if ($cmd-&p_cmd_id & 0) {
//对比当前命令的父命令是否与用户数据中保存的命令id一致
if (intval($user_datas-&last_cmd_id) !== intval($cmd-&p_cmd_id)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_parent_command'));
log_message('error', 'err_incorrect_parent_command');
//检查命令参数是否符合规则
if ('' !== $cmd-&data_regex) {
//检查用户是否输入了参数
if (empty($msg_content[1])) {
//检查用户数据中是否保存有对应命令的数据
if (!isset($data-&$command)) {
//未保存数据且未输入参数
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_command_data'));
log_message('error', 'err_incorrect_command_data');
$cmd_data = $msg_content[1];
$reg = '/' . $cmd-&data_regex . '/';
if (preg_match($reg, $cmd_data, $matches) & 0) {
//形成 命令-&参数 键值对
$data-&$command = $cmd_
//参数不符合命令规则
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_command_data'));
log_message('error', 'err_incorrect_command_data');
//保存用户数据
if (!$this-&_saveDatas($msg-&msgArr['user_opn_id'], $command, $cmd-&id, $data)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_save_user_datas_failed'));
log_message('error', 'err_save_user_datas_failed');
* 若一个命令 with_plugin = 1 表示一个命令流程结束,将前期获取到的userdatas转入第三方处理
* 第三方目前定义为library,建议放置在thirdparty目录下加载
* $this-&load-&library($plugin_name);//载入指定的library
* $this-&$plugin_name-&$plugin_funtion($userdatas);//载入library后执行指定的函数并传入userdatas,该函数可返回回复信息
if (1 === intval($cmd-&is_with_plugin)) {
$lib = $cmd-&plugin_
$fun = $cmd-&plugin_
//获取最终用户数据
$udatas = $this-&_getDatas($msg-&msgArr['user_opn_id']);
//载入指定的library
$this-&load-&add_package_path(APPPATH . 'third_party/' . $lib);
$this-&load-&library($lib);
//载入library后执行指定的function并传入userdatas
$reply = $this-&$lib-&$fun($udatas);
* 函数返回的消息必须是按照正常reply结构组成的对象,否则发送回复会失败
if (!empty($reply) && is_object($reply)) {
$this-&_sendMsg($msg, $reply);
* 检查父命令为当前命令的子命令,获取其保存用户数据,提示用户不需重复输入
* 仅当回复类型设置为text且不为结束命令时有效
if (!empty($cmd-&content) && (0 == $cmd-&is_with_plugin)) {
$ccmd = $this-&_getChildCmd($cmd-&id);
//检查子命令是否需要数据
if ($ccmd && $ccmd-&data_regex) {
$ccommand = $ccmd-&
//子命令是否保存有数据
if (isset($data-&$ccommand)) {
$tip = &\n& . lang('use_saved_data_note1')
. $ccommand . $cmd_sign . $data-&$ccommand
. lang('use_saved_data_note2') . $ccommand . $cmd_
//与原有信息组合
$cmd-&content .= $
$this-&_sendMsg($msg, $cmd);
* 获取子命令
private function _getChildCmd($command_id) {
$this-&load-&model('commands_model', 'cmd');
$c = $this-&cmd-&getChild($command_id);
return $c;
return FALSE;
* 保存用户数据
private function _saveDatas($user_opn_id, $command, $command_id, $data, $confirm = 0) {
$this-&load-&model('datas_model', 'datas');
return $this-&datas-&edit($user_opn_id, $command, $command_id, json_encode($data), $confirm);
* 处理文本类信息
private function _MsgText($msg) {
if ($this-&_isTextCmd($msg)) {
//转到命令处理
$this-&_MsgCmd($msg);
$key = json_decode($msg-&msgArr['content'])-&C
$keyword = $this-&_getKeyword($msg-&msgArr['msgtype_id'], $key);
if (FALSE === $keyword) {
//未查询到合适的关键字
$this-&_sendHelpMsg($msg, 'no_match_keyword');
$reply = $this-&_getReply(intval($keyword-&id));
if (FALSE === $reply) {
//指定关键字没有匹配的回复
$this-&_sendHelpMsg($msg, 'no_match_reply_for_keyword');
$this-&_sendMsg($msg, $reply);
* 获取回复
private function _getReply($keyword_id) {
$this-&load-&model('reply_model', 'reply');
$replys = $this-&reply-&getReplys($keyword_id);
if ($replys) {
return $replys[array_rand($replys)];
return FALSE;
* 回复消息
private function _sendMsg($msg, $reply_msg) {
$this-&load-&model('msgtype_model', 'msgtype');
//获取回复类型的文本值并写入对象,以便执行发送信息操作
if (!empty($reply_msg-&reply_msgtype_id)) {
$reply_msg-&reply_msgtype = $this-&msgtype-&getMsgtype(intval($reply_msg-&reply_msgtype_id))-&type_
$msg-&reply_msg = $reply_
$this-&wechat-&sendMsg($msg);
* 处理事件类信息
private function _MsgEvent($msg) {
$event = json_decode($msg-&msgArr['content'])-&E
$keyword = $this-&_getKeyword($msg-&msgArr['msgtype_id'], $event);
if (FALSE === $keyword) {
//未查询到合适的关键字
$this-&_sendHelpMsg($msg, 'no_match_keyword');
$this-&load-&model('reply_model', 'reply');
$replys = $this-&reply-&getReplys(intval($keyword-&id));
if (FALSE === $replys) {
//指定关键字没有匹配的回复
$this-&_sendHelpMsg($msg, 'no_match_reply_for_keyword');
$this-&_sendMsg($msg, $replys[array_rand($replys)]);
我自己构造了一个请求是可以的啊,
http://42.121.122.74/weixin/?signature=57284f2bce190250dbd65c9d4f66da216da6131b&timestamp=&nonce=AAh9XW&echostr=asdfsa
微信填写的token跟你本地配置的一样吗?是按照wechat_robot_plus要求配置的吗?
是的,token是一样的都是:junxin
我也查看IIS记录,根据:&signature=ffaae4cb6f7f761b22cb&echostr=5392027&timestamp=&nonce=&构造了请求,wechat_robot_plus返回的值也是对的,和http://42.121.122.74/weixin.php返回值来都是一样的。
现在的问题就是,在微信公众平台后台,验证就是通过不了。提示错误,或响应超时。
--- 共有 1 条评论 ---
微信好像有个5s的限制
(3年前)&nbsp&
<span class="a_vote_num" id="a_vote_num_
引用来自“junxincom”的答案引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?! 你的不可以吗?你直接用示例代码都能通过验证的吧? 是的,换成示例代码,就直接通过了。
示例代码的地址是:http://42.121.122.74/weixin.php
我已经不知道问题是怎么回事了。 你可以把你的代码贴出来一下,说不定能找到问题 示例代码就是微信的那个。
* wechat php test
//define your token
define(&TOKEN&, &junxin&);
$wechatObj = new wechatCallbackapiTest();
$wechatObj-&valid();
class wechatCallbackapiTest
public function valid()
$echoStr = $_GET[&echostr&];
//valid signature , option
if($this-&checkSignature()){
echo $echoS
public function responseMsg()
//get post data, May be due to the different environments
$postStr = $GLOBALS[&HTTP_RAW_POST_DATA&];
//extract post data
if (!empty($postStr)){
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUsername = $postObj-&FromUserN
$toUsername = $postObj-&ToUserN
$keyword = trim($postObj-&Content);
$time = time();
$textTpl = &&xml&
&ToUserName&&![CDATA[%s]]&&/ToUserName&
&FromUserName&&![CDATA[%s]]&&/FromUserName&
&CreateTime&%s&/CreateTime&
&MsgType&&![CDATA[%s]]&&/MsgType&
&Content&&![CDATA[%s]]&&/Content&
&FuncFlag&0&/FuncFlag&
if(!empty( $keyword ))
$msgType = &text&;
$contentStr = &Welcome to wechat world!&;
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultS
echo &Input something...&;
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 ){
?& 而且现在通过不了的,就是
的代码啊。配置什么的都做了,就是过不了。
贴一个homephp的代码(好像意义不太大)
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Home extends CI_Controller {
private $runMode = '';
public function __construct() {
parent::__construct();
$this-&load-&library('wechat');
* 运行模式
* 可选: [test][valid][...]
* test: 测试模式,将测试用的XML数据引入程序
* valid: 验证模式,当在微信公众平台开启开发模式时需验证服务器是否配置正确使用
* ...: 除以上状态外的任意设置都是正常运行模式,将正常接收及响应用户的消息
$this-&runMode = 'valid';
public function index() {
switch ($this-&runMode) {
case 'test':
//测试模式
$platform_opn_id = 'platform_opn_id';
$user_opn_id = 'user_opn_id';
$content = 'testfun#123123';
$content = 'cd#5';
$content = 'dc#150';
$content = 'gs#3';
$content = 'dh#';
$content = 'dh#3555555';
$content = 'dz#';
$content = 'dz#安新南区356栋3楼';
$content = 'qr#1';
$xml = '&xml&
&ToUserName&&![CDATA[' . $platform_opn_id . ']]&&/ToUserName&
&FromUserName&&![CDATA[' . $user_opn_id . ']]&&/FromUserName&
&CreateTime&' . time() . '&/CreateTime&
&MsgType&&![CDATA[text]]&&/MsgType&
&Content&&![CDATA[' . $content . ']]&&/Content&
&MsgId&6371514&/MsgId&
$xml = '&xml&
&ToUserName&&![CDATA[' . $platform_opn_id . ']]&&/ToUserName&
&FromUserName&&![CDATA[' . $user_opn_id . ']]&&/FromUserName&
&CreateTime&' . time() . '&/CreateTime&
&MsgType&&![CDATA[event]]&&/MsgType&
&Event&&![CDATA[subscribe]]&&/Event&
&EventKey&&![CDATA[]]&&/EventKey&
$msg = $this-&wechat-&resloveMsg($xml);
if (!is_object($msg)) {
exit($msg);
$this-&_MsgByType($msg-&msgArr['msgtype'], $msg);
case 'valid':
//验证模式
$this-&wechat-&valid($_GET);
//普通运行模式
$postStr = @$GLOBALS['HTTP_RAW_POST_DATA'];
if (!$postStr) {
echo 'err_no_data_gained';
$msg = $this-&wechat-&resloveMsg($postStr);
if (!is_object($msg)) {
exit($msg);
$this-&_MsgByType($msg-&msgArr['msgtype'], $msg);
* 黑名单验证
private function _isBanned($user_opn_id) {
$this-&load-&model('blacklists_model', 'bl');
if (FALSE !== $this-&bl-&get($user_opn_id)) {
return TRUE;
return FALSE;
* 按照不同的消息类型处理
* 目前仅处理文本与事件消息
private function _MsgByType($msgType, $msg) {
//黑名单验证
if ($this-&_isBanned($msg-&msgArr['user_opn_id'])) {
* 用户已被ban,退出
* 这里可以输出一些信息给用户,我就不做了,有兴趣的话可以实现
exit('err_user_has_been_banned');
switch ($msgType) {
case 'text'://文本
$this-&_MsgText($msg);
case 'image'://图像
$this-&_MsgImage();
case 'location'://坐标
$this-&_MsgLocation();
case 'link'://超链接
$this-&_MsgLink();
case 'event'://事件
$this-&_MsgEvent($msg);
case 'voice'://语音
$this-&_MsgVoice();
default://未知类型
$this-&_sendHelpMsg($msg, 'unknown_msg_type');
* 帮助信息
* 这里用作没有匹配到消息类型或者没有合适关键字的时候均调用本过程
* 通常输出一些帮助信息文本
private function _sendHelpMsg($msg, $debug_msg = '') {
* 仅在测试模式下,会将调用本函数时携带的调试信息随着text输出
//获取帮助信息
$k = $this-&_getKeyword(0, $this-&wechat-&help_keyword);
$r = $this-&_getReply($k-&id);
if ('test' == $this-&runMode) {
$r-&content .= &\n\n debug_msg:& . $debug_
$this-&_sendMsg($msg, $r);
* 获取关键字
private function _getKeyword($msgtype_id, $keyword) {
$this-&load-&model('keywords_model', 'keywords');
* 此处getKeyword默认为全匹配模式,同样支持模糊匹配模式
* 具体请查看keywords_model
$keywords = $this-&keywords-&getKeyword($keyword, 0, $msgtype_id, 0);
if (FALSE !== $keywords) {
return $keywords[array_rand($keywords)];
//未查询到合适的关键字
return FALSE;
* 判断用户信息是否含有指定的命令标识
private function _isTextCmd($msg) {
//命令标识
$cmd_sign = $this-&wechat-&cmd_
$content = json_decode($msg-&msgArr['content'])-&C
//检查消息内是否有命令标识
if (FALSE === strpos($content, $cmd_sign)) {
return FALSE;
return TRUE;
* 判断命令是否超时
private function _isExpire($user_datas) {
$cmd_expire_time = $this-&wechat-&cmd_expire_
//当前时间 - 用户上次命令时间 & 超时设置 =& 已超时
if (time() - $user_datas-&last_time & $cmd_expire_time) {
return TRUE;
return FALSE;
* 获取命令设置
private function _getCmd($cmd) {
$this-&load-&model('commands_model', 'cmds');
return $this-&cmds-&get($cmd, 0);
* 获取用户数据
private function _getDatas($user_opn_id) {
$this-&load-&model('datas_model', 'datas');
$d = $this-&datas-&get($user_opn_id);
//查询的用户数据不存在,则新增一条数据
if (FALSE === $d) {
if ($this-&datas-&add($user_opn_id) & 0) {
return $this-&datas-&get($user_opn_id);
return $d;
* 处理文本命令信息
private function _MsgCmd($msg) {
$matches = NULL;
//命令标识
$cmd_sign = $this-&wechat-&cmd_
//分解消息
$msg_content = explode($cmd_sign, json_decode($msg-&msgArr['content'])-&Content);
$cmd = $this-&_getCmd(strtolower($msg_content[0]));
dump($cmd);
//用户输入的命令不存在
if (FALSE === $cmd) {
$this-&_sendMsg($msg, $this-&_getCmd('err_invlid_command'));
log_message('error', 'err_invlid_command');
$command = $cmd-&
//获取用户数据
$user_datas = $this-&_getDatas($msg-&msgArr['user_opn_id']);
//将用户已经保存的数据转化成对象
$data = json_decode(isset($user_datas-&data) ? $user_datas-&data : '');
if (FALSE == $data) {
//若用户未有保存过的数据则新建一个对象
$data = new stdClass();
//检查当前命令是否有超时设置,并检查是否超时
if (1 === intval($cmd-&is_expire)) {
if ($this-&_isExpire($user_datas)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_command_expired'));
log_message('error', 'err_command_expired');
//检查当前输入命令的父命令
if ($cmd-&p_cmd_id & 0) {
//对比当前命令的父命令是否与用户数据中保存的命令id一致
if (intval($user_datas-&last_cmd_id) !== intval($cmd-&p_cmd_id)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_parent_command'));
log_message('error', 'err_incorrect_parent_command');
//检查命令参数是否符合规则
if ('' !== $cmd-&data_regex) {
//检查用户是否输入了参数
if (empty($msg_content[1])) {
//检查用户数据中是否保存有对应命令的数据
if (!isset($data-&$command)) {
//未保存数据且未输入参数
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_command_data'));
log_message('error', 'err_incorrect_command_data');
$cmd_data = $msg_content[1];
$reg = '/' . $cmd-&data_regex . '/';
if (preg_match($reg, $cmd_data, $matches) & 0) {
//形成 命令-&参数 键值对
$data-&$command = $cmd_
//参数不符合命令规则
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_command_data'));
log_message('error', 'err_incorrect_command_data');
//保存用户数据
if (!$this-&_saveDatas($msg-&msgArr['user_opn_id'], $command, $cmd-&id, $data)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_save_user_datas_failed'));
log_message('error', 'err_save_user_datas_failed');
* 若一个命令 with_plugin = 1 表示一个命令流程结束,将前期获取到的userdatas转入第三方处理
* 第三方目前定义为library,建议放置在thirdparty目录下加载
* $this-&load-&library($plugin_name);//载入指定的library
* $this-&$plugin_name-&$plugin_funtion($userdatas);//载入library后执行指定的函数并传入userdatas,该函数可返回回复信息
if (1 === intval($cmd-&is_with_plugin)) {
$lib = $cmd-&plugin_
$fun = $cmd-&plugin_
//获取最终用户数据
$udatas = $this-&_getDatas($msg-&msgArr['user_opn_id']);
//载入指定的library
$this-&load-&add_package_path(APPPATH . 'third_party/' . $lib);
$this-&load-&library($lib);
//载入library后执行指定的function并传入userdatas
$reply = $this-&$lib-&$fun($udatas);
* 函数返回的消息必须是按照正常reply结构组成的对象,否则发送回复会失败
if (!empty($reply) && is_object($reply)) {
$this-&_sendMsg($msg, $reply);
* 检查父命令为当前命令的子命令,获取其保存用户数据,提示用户不需重复输入
* 仅当回复类型设置为text且不为结束命令时有效
if (!empty($cmd-&content) && (0 == $cmd-&is_with_plugin)) {
$ccmd = $this-&_getChildCmd($cmd-&id);
//检查子命令是否需要数据
if ($ccmd && $ccmd-&data_regex) {
$ccommand = $ccmd-&
//子命令是否保存有数据
if (isset($data-&$ccommand)) {
$tip = &\n& . lang('use_saved_data_note1')
. $ccommand . $cmd_sign . $data-&$ccommand
. lang('use_saved_data_note2') . $ccommand . $cmd_
//与原有信息组合
$cmd-&content .= $
$this-&_sendMsg($msg, $cmd);
* 获取子命令
private function _getChildCmd($command_id) {
$this-&load-&model('commands_model', 'cmd');
$c = $this-&cmd-&getChild($command_id);
return $c;
return FALSE;
* 保存用户数据
private function _saveDatas($user_opn_id, $command, $command_id, $data, $confirm = 0) {
$this-&load-&model('datas_model', 'datas');
return $this-&datas-&edit($user_opn_id, $command, $command_id, json_encode($data), $confirm);
* 处理文本类信息
private function _MsgText($msg) {
if ($this-&_isTextCmd($msg)) {
//转到命令处理
$this-&_MsgCmd($msg);
$key = json_decode($msg-&msgArr['content'])-&C
$keyword = $this-&_getKeyword($msg-&msgArr['msgtype_id'], $key);
if (FALSE === $keyword) {
//未查询到合适的关键字
$this-&_sendHelpMsg($msg, 'no_match_keyword');
$reply = $this-&_getReply(intval($keyword-&id));
if (FALSE === $reply) {
//指定关键字没有匹配的回复
$this-&_sendHelpMsg($msg, 'no_match_reply_for_keyword');
$this-&_sendMsg($msg, $reply);
* 获取回复
private function _getReply($keyword_id) {
$this-&load-&model('reply_model', 'reply');
$replys = $this-&reply-&getReplys($keyword_id);
if ($replys) {
return $replys[array_rand($replys)];
return FALSE;
* 回复消息
private function _sendMsg($msg, $reply_msg) {
$this-&load-&model('msgtype_model', 'msgtype');
//获取回复类型的文本值并写入对象,以便执行发送信息操作
if (!empty($reply_msg-&reply_msgtype_id)) {
$reply_msg-&reply_msgtype = $this-&msgtype-&getMsgtype(intval($reply_msg-&reply_msgtype_id))-&type_
$msg-&reply_msg = $reply_
$this-&wechat-&sendMsg($msg);
* 处理事件类信息
private function _MsgEvent($msg) {
$event = json_decode($msg-&msgArr['content'])-&E
$keyword = $this-&_getKeyword($msg-&msgArr['msgtype_id'], $event);
if (FALSE === $keyword) {
//未查询到合适的关键字
$this-&_sendHelpMsg($msg, 'no_match_keyword');
$this-&load-&model('reply_model', 'reply');
$replys = $this-&reply-&getReplys(intval($keyword-&id));
if (FALSE === $replys) {
//指定关键字没有匹配的回复
$this-&_sendHelpMsg($msg, 'no_match_reply_for_keyword');
$this-&_sendMsg($msg, $replys[array_rand($replys)]);
我自己构造了一个请求是可以的啊,
http://42.121.122.74/weixin/?signature=57284f2bce190250dbd65c9d4f66da216da6131b&timestamp=&nonce=AAh9XW&echostr=asdfsa
微信填写的token跟你本地配置的一样吗?是按照wechat_robot_plus要求配置的吗?
<span class="a_vote_num" id="a_vote_num_
引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?! 你的不可以吗?你直接用示例代码都能通过验证的吧? 是的,换成示例代码,就直接通过了。
示例代码的地址是:http://42.121.122.74/weixin.php
我已经不知道问题是怎么回事了。 你可以把你的代码贴出来一下,说不定能找到问题 示例代码就是微信的那个。
* wechat php test
//define your token
define(&TOKEN&, &junxin&);
$wechatObj = new wechatCallbackapiTest();
$wechatObj-&valid();
class wechatCallbackapiTest
public function valid()
$echoStr = $_GET[&echostr&];
//valid signature , option
if($this-&checkSignature()){
echo $echoS
public function responseMsg()
//get post data, May be due to the different environments
$postStr = $GLOBALS[&HTTP_RAW_POST_DATA&];
//extract post data
if (!empty($postStr)){
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUsername = $postObj-&FromUserN
$toUsername = $postObj-&ToUserN
$keyword = trim($postObj-&Content);
$time = time();
$textTpl = &&xml&
&ToUserName&&![CDATA[%s]]&&/ToUserName&
&FromUserName&&![CDATA[%s]]&&/FromUserName&
&CreateTime&%s&/CreateTime&
&MsgType&&![CDATA[%s]]&&/MsgType&
&Content&&![CDATA[%s]]&&/Content&
&FuncFlag&0&/FuncFlag&
if(!empty( $keyword ))
$msgType = &text&;
$contentStr = &Welcome to wechat world!&;
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultS
echo &Input something...&;
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 ){
?& 而且现在通过不了的,就是
的代码啊。配置什么的都做了,就是过不了。
贴一个homephp的代码(好像意义不太大)
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Home extends CI_Controller {
private $runMode = '';
public function __construct() {
parent::__construct();
$this-&load-&library('wechat');
* 运行模式
* 可选: [test][valid][...]
* test: 测试模式,将测试用的XML数据引入程序
* valid: 验证模式,当在微信公众平台开启开发模式时需验证服务器是否配置正确使用
* ...: 除以上状态外的任意设置都是正常运行模式,将正常接收及响应用户的消息
$this-&runMode = 'valid';
public function index() {
switch ($this-&runMode) {
case 'test':
//测试模式
$platform_opn_id = 'platform_opn_id';
$user_opn_id = 'user_opn_id';
$content = 'testfun#123123';
$content = 'cd#5';
$content = 'dc#150';
$content = 'gs#3';
$content = 'dh#';
$content = 'dh#3555555';
$content = 'dz#';
$content = 'dz#安新南区356栋3楼';
$content = 'qr#1';
$xml = '&xml&
&ToUserName&&![CDATA[' . $platform_opn_id . ']]&&/ToUserName&
&FromUserName&&![CDATA[' . $user_opn_id . ']]&&/FromUserName&
&CreateTime&' . time() . '&/CreateTime&
&MsgType&&![CDATA[text]]&&/MsgType&
&Content&&![CDATA[' . $content . ']]&&/Content&
&MsgId&6371514&/MsgId&
$xml = '&xml&
&ToUserName&&![CDATA[' . $platform_opn_id . ']]&&/ToUserName&
&FromUserName&&![CDATA[' . $user_opn_id . ']]&&/FromUserName&
&CreateTime&' . time() . '&/CreateTime&
&MsgType&&![CDATA[event]]&&/MsgType&
&Event&&![CDATA[subscribe]]&&/Event&
&EventKey&&![CDATA[]]&&/EventKey&
$msg = $this-&wechat-&resloveMsg($xml);
if (!is_object($msg)) {
exit($msg);
$this-&_MsgByType($msg-&msgArr['msgtype'], $msg);
case 'valid':
//验证模式
$this-&wechat-&valid($_GET);
//普通运行模式
$postStr = @$GLOBALS['HTTP_RAW_POST_DATA'];
if (!$postStr) {
echo 'err_no_data_gained';
$msg = $this-&wechat-&resloveMsg($postStr);
if (!is_object($msg)) {
exit($msg);
$this-&_MsgByType($msg-&msgArr['msgtype'], $msg);
* 黑名单验证
private function _isBanned($user_opn_id) {
$this-&load-&model('blacklists_model', 'bl');
if (FALSE !== $this-&bl-&get($user_opn_id)) {
return TRUE;
return FALSE;
* 按照不同的消息类型处理
* 目前仅处理文本与事件消息
private function _MsgByType($msgType, $msg) {
//黑名单验证
if ($this-&_isBanned($msg-&msgArr['user_opn_id'])) {
* 用户已被ban,退出
* 这里可以输出一些信息给用户,我就不做了,有兴趣的话可以实现
exit('err_user_has_been_banned');
switch ($msgType) {
case 'text'://文本
$this-&_MsgText($msg);
case 'image'://图像
$this-&_MsgImage();
case 'location'://坐标
$this-&_MsgLocation();
case 'link'://超链接
$this-&_MsgLink();
case 'event'://事件
$this-&_MsgEvent($msg);
case 'voice'://语音
$this-&_MsgVoice();
default://未知类型
$this-&_sendHelpMsg($msg, 'unknown_msg_type');
* 帮助信息
* 这里用作没有匹配到消息类型或者没有合适关键字的时候均调用本过程
* 通常输出一些帮助信息文本
private function _sendHelpMsg($msg, $debug_msg = '') {
* 仅在测试模式下,会将调用本函数时携带的调试信息随着text输出
//获取帮助信息
$k = $this-&_getKeyword(0, $this-&wechat-&help_keyword);
$r = $this-&_getReply($k-&id);
if ('test' == $this-&runMode) {
$r-&content .= &\n\n debug_msg:& . $debug_
$this-&_sendMsg($msg, $r);
* 获取关键字
private function _getKeyword($msgtype_id, $keyword) {
$this-&load-&model('keywords_model', 'keywords');
* 此处getKeyword默认为全匹配模式,同样支持模糊匹配模式
* 具体请查看keywords_model
$keywords = $this-&keywords-&getKeyword($keyword, 0, $msgtype_id, 0);
if (FALSE !== $keywords) {
return $keywords[array_rand($keywords)];
//未查询到合适的关键字
return FALSE;
* 判断用户信息是否含有指定的命令标识
private function _isTextCmd($msg) {
//命令标识
$cmd_sign = $this-&wechat-&cmd_
$content = json_decode($msg-&msgArr['content'])-&C
//检查消息内是否有命令标识
if (FALSE === strpos($content, $cmd_sign)) {
return FALSE;
return TRUE;
* 判断命令是否超时
private function _isExpire($user_datas) {
$cmd_expire_time = $this-&wechat-&cmd_expire_
//当前时间 - 用户上次命令时间 & 超时设置 =& 已超时
if (time() - $user_datas-&last_time & $cmd_expire_time) {
return TRUE;
return FALSE;
* 获取命令设置
private function _getCmd($cmd) {
$this-&load-&model('commands_model', 'cmds');
return $this-&cmds-&get($cmd, 0);
* 获取用户数据
private function _getDatas($user_opn_id) {
$this-&load-&model('datas_model', 'datas');
$d = $this-&datas-&get($user_opn_id);
//查询的用户数据不存在,则新增一条数据
if (FALSE === $d) {
if ($this-&datas-&add($user_opn_id) & 0) {
return $this-&datas-&get($user_opn_id);
return $d;
* 处理文本命令信息
private function _MsgCmd($msg) {
$matches = NULL;
//命令标识
$cmd_sign = $this-&wechat-&cmd_
//分解消息
$msg_content = explode($cmd_sign, json_decode($msg-&msgArr['content'])-&Content);
$cmd = $this-&_getCmd(strtolower($msg_content[0]));
dump($cmd);
//用户输入的命令不存在
if (FALSE === $cmd) {
$this-&_sendMsg($msg, $this-&_getCmd('err_invlid_command'));
log_message('error', 'err_invlid_command');
$command = $cmd-&
//获取用户数据
$user_datas = $this-&_getDatas($msg-&msgArr['user_opn_id']);
//将用户已经保存的数据转化成对象
$data = json_decode(isset($user_datas-&data) ? $user_datas-&data : '');
if (FALSE == $data) {
//若用户未有保存过的数据则新建一个对象
$data = new stdClass();
//检查当前命令是否有超时设置,并检查是否超时
if (1 === intval($cmd-&is_expire)) {
if ($this-&_isExpire($user_datas)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_command_expired'));
log_message('error', 'err_command_expired');
//检查当前输入命令的父命令
if ($cmd-&p_cmd_id & 0) {
//对比当前命令的父命令是否与用户数据中保存的命令id一致
if (intval($user_datas-&last_cmd_id) !== intval($cmd-&p_cmd_id)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_parent_command'));
log_message('error', 'err_incorrect_parent_command');
//检查命令参数是否符合规则
if ('' !== $cmd-&data_regex) {
//检查用户是否输入了参数
if (empty($msg_content[1])) {
//检查用户数据中是否保存有对应命令的数据
if (!isset($data-&$command)) {
//未保存数据且未输入参数
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_command_data'));
log_message('error', 'err_incorrect_command_data');
$cmd_data = $msg_content[1];
$reg = '/' . $cmd-&data_regex . '/';
if (preg_match($reg, $cmd_data, $matches) & 0) {
//形成 命令-&参数 键值对
$data-&$command = $cmd_
//参数不符合命令规则
$this-&_sendMsg($msg, $this-&_getCmd('err_incorrect_command_data'));
log_message('error', 'err_incorrect_command_data');
//保存用户数据
if (!$this-&_saveDatas($msg-&msgArr['user_opn_id'], $command, $cmd-&id, $data)) {
$this-&_sendMsg($msg, $this-&_getCmd('err_save_user_datas_failed'));
log_message('error', 'err_save_user_datas_failed');
* 若一个命令 with_plugin = 1 表示一个命令流程结束,将前期获取到的userdatas转入第三方处理
* 第三方目前定义为library,建议放置在thirdparty目录下加载
* $this-&load-&library($plugin_name);//载入指定的library
* $this-&$plugin_name-&$plugin_funtion($userdatas);//载入library后执行指定的函数并传入userdatas,该函数可返回回复信息
if (1 === intval($cmd-&is_with_plugin)) {
$lib = $cmd-&plugin_
$fun = $cmd-&plugin_
//获取最终用户数据
$udatas = $this-&_getDatas($msg-&msgArr['user_opn_id']);
//载入指定的library
$this-&load-&add_package_path(APPPATH . 'third_party/' . $lib);
$this-&load-&library($lib);
//载入library后执行指定的function并传入userdatas
$reply = $this-&$lib-&$fun($udatas);
* 函数返回的消息必须是按照正常reply结构组成的对象,否则发送回复会失败
if (!empty($reply) && is_object($reply)) {
$this-&_sendMsg($msg, $reply);
* 检查父命令为当前命令的子命令,获取其保存用户数据,提示用户不需重复输入
* 仅当回复类型设置为text且不为结束命令时有效
if (!empty($cmd-&content) && (0 == $cmd-&is_with_plugin)) {
$ccmd = $this-&_getChildCmd($cmd-&id);
//检查子命令是否需要数据
if ($ccmd && $ccmd-&data_regex) {
$ccommand = $ccmd-&
//子命令是否保存有数据
if (isset($data-&$ccommand)) {
$tip = &\n& . lang('use_saved_data_note1')
. $ccommand . $cmd_sign . $data-&$ccommand
. lang('use_saved_data_note2') . $ccommand . $cmd_
//与原有信息组合
$cmd-&content .= $
$this-&_sendMsg($msg, $cmd);
* 获取子命令
private function _getChildCmd($command_id) {
$this-&load-&model('commands_model', 'cmd');
$c = $this-&cmd-&getChild($command_id);
return $c;
return FALSE;
* 保存用户数据
private function _saveDatas($user_opn_id, $command, $command_id, $data, $confirm = 0) {
$this-&load-&model('datas_model', 'datas');
return $this-&datas-&edit($user_opn_id, $command, $command_id, json_encode($data), $confirm);
* 处理文本类信息
private function _MsgText($msg) {
if ($this-&_isTextCmd($msg)) {
//转到命令处理
$this-&_MsgCmd($msg);
$key = json_decode($msg-&msgArr['content'])-&C
$keyword = $this-&_getKeyword($msg-&msgArr['msgtype_id'], $key);
if (FALSE === $keyword) {
//未查询到合适的关键字
$this-&_sendHelpMsg($msg, 'no_match_keyword');
$reply = $this-&_getReply(intval($keyword-&id));
if (FALSE === $reply) {
//指定关键字没有匹配的回复
$this-&_sendHelpMsg($msg, 'no_match_reply_for_keyword');
$this-&_sendMsg($msg, $reply);
* 获取回复
private function _getReply($keyword_id) {
$this-&load-&model('reply_model', 'reply');
$replys = $this-&reply-&getReplys($keyword_id);
if ($replys) {
return $replys[array_rand($replys)];
return FALSE;
* 回复消息
private function _sendMsg($msg, $reply_msg) {
$this-&load-&model('msgtype_model', 'msgtype');
//获取回复类型的文本值并写入对象,以便执行发送信息操作
if (!empty($reply_msg-&reply_msgtype_id)) {
$reply_msg-&reply_msgtype = $this-&msgtype-&getMsgtype(intval($reply_msg-&reply_msgtype_id))-&type_
$msg-&reply_msg = $reply_
$this-&wechat-&sendMsg($msg);
* 处理事件类信息
private function _MsgEvent($msg) {
$event = json_decode($msg-&msgArr['content'])-&E
$keyword = $this-&_getKeyword($msg-&msgArr['msgtype_id'], $event);
if (FALSE === $keyword) {
//未查询到合适的关键字
$this-&_sendHelpMsg($msg, 'no_match_keyword');
$this-&load-&model('reply_model', 'reply');
$replys = $this-&reply-&getReplys(intval($keyword-&id));
if (FALSE === $replys) {
//指定关键字没有匹配的回复
$this-&_sendHelpMsg($msg, 'no_match_reply_for_keyword');
$this-&_sendMsg($msg, $replys[array_rand($replys)]);
<span class="a_vote_num" id="a_vote_num_
引用来自“junxincom”的答案引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?! 你的不可以吗?你直接用示例代码都能通过验证的吧? 是的,换成示例代码,就直接通过了。
示例代码的地址是:http://42.121.122.74/weixin.php
我已经不知道问题是怎么回事了。 你可以把你的代码贴出来一下,说不定能找到问题
<span class="a_vote_num" id="a_vote_num_
引用来自“水陌流光”的答案引用来自“junxincom”的答案引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?! 你的不可以吗?你直接用示例代码都能通过验证的吧? 是的,换成示例代码,就直接通过了。
示例代码的地址是:http://42.121.122.74/weixin.php
我已经不知道问题是怎么回事了。
<span class="a_vote_num" id="a_vote_num_
引用来自“junxincom”的答案引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?! 你的不可以吗?你直接用示例代码都能通过验证的吧?
<span class="a_vote_num" id="a_vote_num_
引用来自“水陌流光”的答案你可以自己模拟微信发送一下请求试试,自己拼数据,正确了在提交,或者看下你的apache日志,微信访问的那个请求的状态是什么 已经模拟了。返回码是正确的,但就是通过不了。
用微信的那个示例代码测试了 一下,返回码一样。但那个就能通过验证?!
更多开发者职位上
有什么技术问题吗?
类似的话题}

我要回帖

更多关于 php微信token验证失败 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信