測試可以正常返回,結(jié)果都正常,但是公眾號里一直提示:“該公眾號提供的服務(wù)出現(xiàn)故障,請稍后再試”
倒騰一下午了,迫不得已才來請幫忙,幫一下
http://119.45.5.37/wechat/wechat.php
返回結(jié)果:
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;