有大神知道我這個關(guān)注之后沒反應是什么情況
public function reponseMsg(){
// 獲取到微信推送過來post數(shù)據(jù)(xml格式)
$postArr = file_get_contents('php://input');
libxml_disable_entity_loader(true);
// 處理消息類型,并設置回復類型和內(nèi)容
$postObj = simplexml_load_string($postArr);
//判斷該數(shù)據(jù)包是否是訂閱的事件推送
if(strtolower($postObj->MsgType) == 'event'){
//如果是關(guān)注 subscribe 事件
if(strtolower($postObj->Event == 'subscribe')){
//回復用戶消息(純文本格式)
$toUser ? = $postObj->FromUserName;
$fromUser = $postObj->ToUserName;
$time ? ? = time();
$msgType ?= 'text';
$content ?= '歡迎關(guān)注小蔥的微信公眾賬號';
$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;
}
}
}
2019-07-15
函數(shù)有沒有被調(diào)用