不走else区间 这样的情况有大佬出现过吗
不用框架的时候 都好使 用了tp5 然后用的route路由 微信配置中的url是 http://www.xxxx/api/wei/check token 认证是可以的 我在else区间调用了关注回复 但是没有回复 然后我调用了自定义菜单(测试走不走else区间)还是不行 单独用自定义菜单是可以的 哪位大佬出现过这个情况
public function check_wei()
{
if(isset($_GET['echostr'])) {
$nonce = $_GET['nonce'];
$token = 'bijiwang123456';
$timestamp = $_GET['timestamp'];
$echostr = $_GET['echostr'];
$signature = $_GET['signature'];
$array = array($nonce, $timestamp, $token);
sort($array);
$str = sha1(implode($array));
if($str == $signature ) {
echo $echostr;
exit;
}
}
$this->sendMsg();
}
public function sendMsg()
{
$post_data = file_get_contents('php://input');//获得微信推送过得post数据(xml格式)
file_put_contents('ceshi.txt',$post_data);
$post_obj = simplexml_load_string($post_data);//处理消息
if(strtolower($post_obj->MsgType) == 'event') {//判断是否是订阅的时间推送
if(strtolower($post_obj->Event) == 'subscribe') {//判断是否是关注事件
$toUser = $post_obj->FromUserName;
$fromUser = $post_obj->ToUserName;
$time = time();
$msgType = 'text';
$content = '欢迎关注';
$template = "
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>
";
$info = sprintf($template,$toUser,$fromUser,$time,$msgType,$content);
echo $info;
}
}
}