测试可以正常返回,结果都正常,但是公众号里一直提示:“该公众号提供的服务出现故障,请稍后再试”
倒腾一下午了,迫不得已才来请帮忙,帮一下
http://119.45.5.37/wechat/wechat.php
返回结果:
200 OK
Connection: Keep-Alive
Date: Mon, 01 Jun 2020 12:51:08 GMT
X-Powered-By: PHP/5.6.40
Server: Apache/2.4.37 (Win64) PHP/5.6.40
Content-Type: text/html; charset=UTF-8
Content-Length: 353
<xml> <ToUserName> <![CDATA[bbbbbbb]]> </ToUserName> <FromUserName> <![CDATA[aaaaaaa]]> </FromUserName> <CreateTime>1591015869</CreateTime> <MsgType> <![CDATA[text]]> </MsgType> <Content> <![CDATA[你好啊啊啊]]> </Content> <FuncFlag>0</FuncFlag> </xml>
$postStr = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input");$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);$fromUsername = $postObj->FromUserName;$toUsername = $postObj->ToUserName;$keyword = trim($postObj->Content);$msgType = $postObj -> MsgType;$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> </xml>";$msgType = "text";$contentStr = "你好";$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);echo $resultStr;