測試可以正常返回,結果都正常,但是公眾號裡一直提示:「該公眾號提供的服務出現故障,請稍後再試」
#倒騰一下午了,迫不得已才來請幫忙,幫一下
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_NOplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOplexATA); toUsername = $postObj->ToUserName;$keyword = trim($postObj->Content);$msgType = $postObj -> MsgType;$time = time();$textTpl = "<xml> ;<![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> _ltlt;![CDATA[%s]]></FromUserName> <lt;![CDATA[%s]]></FromUserName> <lt;lt;CreateTime<); ;MsgType><![CDATA[%s]]></MsgType> <Content><![CDATA[%s]]></Content> </xml>";$msgType = "text";$contentStr = "你好";$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);echo $resultStr;